使用 WordPress 搭建企業站點的時候,後台儀表盤頁面裏很多模塊 (WordPress 新聞、開發日誌、 Welcome 等等) 是不需要的,後台導航欄上的 「顯示選項」 和 「幫助」 下拉菜單選項卡用處也不大。使用下面的代碼可以將它們 「屏蔽」 掉。
編輯你當前使用 WordPress 主題 模板中的 functions.php 文件,根據需要添加下列代碼:
屏蔽 WP 後台 「顯示選項」 和 「幫助」 選項卡
- function remove_screen_options(){ return false;}
- function wpse50723_remove_help($old_help, $screen_id, $screen){
- $screen->remove_help_tabs();
- return $old_help;
- }
屏蔽後台儀表盤無用模塊
- function example_remove_dashboard_widgets() {
- global $wp_meta_boxes;
- $wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);
- unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);
- $wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
- unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']);
- $wp_meta_boxes['dashboard']['side']['core']['dashboard_recent_drafts']);
- unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
- $wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);
- unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
- add_action('wp_dashboard_setup', 'example_remove_dashboard_widgets' );