使用 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' );