移除WordPress 仪表盘首页的“插件”“其它WordPress 新闻”小工具

时间:2022-04-23
本文章向大家介绍移除WordPress 仪表盘首页的“插件”“其它WordPress 新闻”小工具,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

WordPress 的后台管理首页(仪表盘首页)有不少小工具,比如说“概况”、“近期草稿”、“近期评论”等等小工具,如果你对一些小工具不那么顺言(比如题目所说的“插件”、“其它WordPress 新闻”小工具),可以通过上面“显示选项”来决定显示与否。同时,你也可以使用下面的代码来删除之。

//移除WordPress 仪表盘首页的“插件”“其它WordPress 新闻”小工具 function remove_dashboard_widgets() { global$wp_meta_boxes; unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']); unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']); } add_action('wp_dashboard_setup', 'remove_dashboard_widgets');

上面的例子是移除WordPress 仪表盘首页的“插件”“其它WordPress 新闻”小工具的代码,具体对应的是:“插件”小工具——dashboard_plugins;“其它WordPress 新闻”小工具——dashboard_secondary。如下图:

其他小工具的“英文”名字如何寻找?可以通过审查元素的方法,比如通过审查元素,“近期草稿”小工具所在的html 代码如下:

<div id="dashboard_recent_drafts" class="postbox "> <div class="handlediv" title="点击以切换"><br></div><h3 class="hndle"><span>近期草稿</span></h3> <div class="inside"> 当前没有草稿</div> </div>

选择器id 是dashboard_recent_drafts,那么其“英文名”就是这个了。