wordpress 开发侧边栏的时候,在后台会有很多原生的 WordPress 小工具,也就是默认的 Widget 有时候并不适合我们。所以为自己的 WordPress 主题自定义小工具是个非常明智的选择,这样一来我们需要屏蔽无用的 WordPress 默认小工具,那么如何屏蔽无用的原生的默认WordPress 小工具?接下来为大家分享一个小方法。

add_action(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’widgets_init\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’, \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’my_unregister_widgets\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’);

function my_unregister_widgets() {

unregister_widget(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’WP_Widget_Archives\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’);

unregister_widget(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’WP_Widget_Calendar\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’);

unregister_widget(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’WP_Widget_Categories\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’);

unregister_widget(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’WP_Widget_Links\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’);

unregister_widget(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’WP_Widget_Meta\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’);

unregister_widget(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’WP_Widget_Pages\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’);

unregister_widget(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’WP_Widget_Recent_Comments\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’);

unregister_widget(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’WP_Widget_Recent_Posts\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’);

unregister_widget(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’WP_Widget_RSS\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’);

unregister_widget(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’WP_Widget_Search\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’);

unregister_widget(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’WP_Widget_Tag_Cloud\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’);

unregister_widget(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’WP_Widget_Text\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’);

unregister_widget(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’WP_Nav_Menu_Widget\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’);

unregister_widget(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’WP_Widget_Media_Image\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’);

unregister_widget(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’WP_Widget_Media_Gallery\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’);

unregister_widget(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’WP_Widget_Media_Video\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’);

unregister_widget(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’WP_Widget_Media_Audio\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’);

}

将上面面代码加到WordPress主题functions模版中即可,之前已启用的默认小工具将失效。

相关新闻

发表评论

您的电子邮箱地址不会被公开。

联系我们

联系我们

151-1101-0018

在线咨询:
邮件:30115776@qq.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信
关注微信
分享本页
返回顶部