使用 WordPress 搭建企業站點的時候,后臺儀表盤頁面里很多模塊(Wordpress 新聞、開發日志、Welcome等等)是不需要的,后臺導航欄上的“顯示選項”和“幫助”下拉菜單選項卡用處也不大。使用下面的代碼可以將它們“屏蔽”掉。
編輯你當前使用 wordpress主題 模板中的 functions.php 文件,根據需要添加下列代碼:
屏蔽 WP 后臺“顯示選項”和“幫助”選項卡
- function?remove_screen_options(){?return?false;}
- ????add_filter('screen_options_show_screen',?'remove_screen_options');
- ????add_filter(?'contextual_help',?'wpse50723_remove_help',?999,?3?);
- ????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;
-
-
- unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);
-
-
- unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);
-
-
- unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
-
-
- unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']);
-
-
- unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_recent_drafts']);
-
-
- unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
-
-
- unset($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' );