wordpress留言板_如何删除WordPress仪表板小部件

wordpress留言板

Have you ever worked on a project which required you to customize the display of the WordPress admin panel? Well one of the first things consultants customize is the WordPress Dashboard. We showed you a quick example of how to add custom dashboard widgets in WordPress. In this article, we will show you how to remove WordPress dashboard widgets.

您是否曾经从事过一个需要自定义WordPress管理面板显示的项目? 顾问定制的第一件事就是WordPress仪表板。 我们向您展示了如何在WordPress中添加自定义仪表板小部件的快速示例。 在本文中,我们将向您展示如何删除WordPress仪表板小部件。

Note: If you ended up on this article looking for how to remove dashboard widgets just for yourself, then you should probably look at our article: How to Customize WordPress Admin Area (Dashboard) for Beginners

注意:如果您最终在本文中找到了如何仅为自己删除仪表板小部件,那么您可能应该看看我们的文章: 如何为初学者定制WordPress管理区域(仪表板)

All you have to do is simply paste the following code in your theme’s functions.php file. Although it maybe a good idea to save this file as a plugin and make it a drop-in plugin.

您所要做的只是简单地将以下代码粘贴到主题的functions.php文件中。 尽管将这个文件另存为插件并使其成为嵌入式插件可能是个好主意。


function 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_right_now']);
	unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
	unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_drafts']);
	unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']);
	unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
	unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);

}

add_action('wp_dashboard_setup', 'remove_dashboard_widgets' );


Each of the widgets listed above are pretty self-explanatory. You can keep the ones you want by simply removing them from the list. If you want to remove these widgets from all users except for admins, then just change the last line to this:

上面列出的每个小部件都很容易解释。 您只需将其从列表中删除,即可保留所需的内容。 如果要从除管理员以外的所有用户中删除这些小部件,只需将最后一行更改为:


if (!current_user_can('manage_options')) {
	add_action('wp_dashboard_setup', 'remove_dashboard_widgets' );
}

We hope that this article helped you remove the default dashboard widgets in WordPress.

我们希望本文能帮助您删除WordPress中的默认仪表板小部件。

翻译自: https://www.wpbeginner.com/wp-tutorials/how-to-remove-wordpress-dashboard-widgets/

wordpress留言板

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值