如何在wordpress中禁用侧边栏

Raj*_*jat 2 wordpress

我正在使用带有两个侧边栏的wordpress主题.我想为特定页面禁用一个,但我找到的关于通过应用检查功能来禁用侧边栏的代码:

<?php get_sidebar() ?>
Run Code Online (Sandbox Code Playgroud)

它将禁用它们.我怎样才能禁用其中一个.与另一边工作.

请帮忙!!!!

The*_*pha 5

你可以简单地举个例子

<?php if (!is_page('about-me')) get_sidebar(); ?>
Run Code Online (Sandbox Code Playgroud)

这将禁用关于我页面的侧栏.如果你把它放在page.php(如果有的话),否则把它放在index.php上.这里'about-me'是页面slug,但你也可以使用像is_page(5)这样的页面ID以及页面标题.要使用slug,id和title检查多个页面,您可以使用类似的数组

is_page(array(42,'about-me','Contact'));
Run Code Online (Sandbox Code Playgroud)

有关is_page()函数的更多信息,请参阅http://codex.wordpress.org/Function_Reference/is_page

或者在functions.php中使用过滤器,只需将其放在functions.php中即可

function disable_footer_widgets( $sidebars_widgets )
{
    if (is_single())
    {
        $sidebars_widgets['footer'] = false;
    }   
    return $sidebars_widgets;
}
add_filter( 'sidebars_widgets', 'disable_footer_widgets' );
Run Code Online (Sandbox Code Playgroud)

这只是一个示例,您必须更改小部件名称.