使用 WordPress 搭建企業站點的時候,後台儀表盤頁面裏很多模塊 (Wordpress 新聞、開發日誌、 Welcome 等等) 是不需要的,後台導航欄上的 「顯示選項」 和 「幫助」 下拉菜單選項卡用處也不大。使用下面的代碼可以將它們 「屏蔽」 掉。

編輯你當前使用 wordpress 主題 模板中的 functions.php 文件,根據需要添加下列代碼:

屏蔽 WP 後台 「顯示選項」 和 「幫助」 選項卡

  1. function remove_screen_options(){ return false;}
  2.     add_filter('screen_options_show_screen', 'remove_screen_options');
  3.     add_filter( 'contextual_help', 'wpse50723_remove_help', 999, 3 );
  4.     function wpse50723_remove_help($old_help, $screen_id, $screen){
  5.     $screen->remove_help_tabs();
  6.     return $old_help;
  7. }

屏蔽後台儀表盤無用模塊

  1. function example_remove_dashboard_widgets() {  
  2.     // Globalize the metaboxes array, this holds all the widgets for wp-admin  
  3.     global $wp_meta_boxes;  
  4.    
  5.     // 以下這一行代碼將刪除 "快速發佈" 模塊  
  6.     unset($wp_meta_boxes
    ['dashboard']['side']['core']['dashboard_quick_press']);  
  7.    
  8.     // 以下這一行代碼將刪除 "引入鏈接" 模塊  
  9.     unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);  
  10.    
  11.     // 以下這一行代碼將刪除 "插件" 模塊  
  12.     unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);  
  13.    
  14.     // 以下這一行代碼將刪除 "近期評論" 模塊  
  15.     unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']);  
  16.    
  17.     // 以下這一行代碼將刪除 "近期草稿" 模塊  
  18.     unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_recent_drafts']);  
  19.    
  20.     // 以下這一行代碼將刪除 "WordPress 開發日誌" 模塊  
  21.     unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);  
  22.    
  23.     // 以下這一行代碼將刪除 "其它 WordPress 新聞" 模塊  
  24.     unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);  
  25.    
  26.     // 以下這一行代碼將刪除 "概況" 模塊  
  27.     unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);  
  28. }  
  29. add_action('wp_dashboard_setup', 'example_remove_dashboard_widgets' );