如果想删除 WordPress 后台的仪表盘活动、快速草稿、概览和 WordPress 活动及新闻等模块,只需要将下面的代码添加到当前主题的 functions.php 文件中即可:
//删除 WordPress 后台仪表盘
function disable_dashboard_widgets() {
global $wp_meta_boxes;
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_activity']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_recent_drafts']);
}
add_action('wp_dashboard_setup', 'disable_dashboard_widgets', 999);
其中以上代码无法删除 Welcome 模块,可以在“显示选项”中不勾选“Welcome”模块即可。
以上内容整理自@知更鸟
如果想要移除仪表盘中的“欢迎”模块,只需要将以下代码添加到当前主题的 functions.php 文件中即可:
//WordPress 彻底移除后台仪表盘欢迎使用
add_action( 'load-index.php', 'remove_welcome_panel' );
function remove_welcome_panel(){
remove_action('welcome_panel', 'wp_welcome_panel');
delete_user_meta( get_current_user_id(), 'show_welcome_panel' );
}
以上内容整理自@泪雪博客