首页 > 新闻资讯 > 特定页面禁用widgets

特定页面禁用widgets

7条评论
标签:
更多

使用这段代码可以在你指定的页面禁用widget,而不需要设置整个网站完全禁用widget。下面这段代码以home页为例,你可以改成你需要的指定页面。

<?php
add_filter( 'sidebars_widgets', 'disable_all_widgets' );
function disable_all_widgets( $sidebars_widgets ) {
    if ( is_home() )
        $sidebars_widgets = array( false );
    return $sidebars_widgets;
}?>

* 版权声明:作者WordPress啦! 转载请注明出处。

#1
原来还有这样的东东。不错哟,得试一试才行
#2
这个还没有用过
#3
比较有专业性的
#4
没看懂。
#5
还是不大熟悉。
#6
比较有专业性的
#7
还是不大熟悉。

发表新评论

此内容将保密,不会被其他人看见。
  • 自动将网址与电子邮件地址转变为链接。
  • 允许HTML标签:<a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • 自动断行和分段。

更多关於格式化选项的信息

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.