2

I am using a wordpress theme with two sidebars. I want to disable one for them for a specific page but the code I found regarding disabling sidebar by applying check on function:

<?php get_sidebar() ?>

It will disable both of them. How can I disable one of them only. with the other sidebar working.

Please help!!!!

1
  • I am using Contentville theme
    – Rajat
    Feb 17, 2012 at 7:04

1 Answer 1

5

You can simply for example

<?php if (!is_page('about-me')) get_sidebar(); ?>

This will disable sidebar on about me page. If you put this on page.php (if have any) otherwise put this on index.php. Here 'about-me' is page slug but you can also use page id like is_page(5) and as well as page title too. To check multiple page using slug, id and title you can use an array like

is_page(array(42,'about-me','Contact'));

For more about is_page() function see http://codex.wordpress.org/Function_Reference/is_page

Or using filter in functions.php, simply put this in 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' );

This is just an example, you have to change widget name.

1
  • You don't get my question. I want to disable only one widget and display the other. But your code is for disabling all the widgets i have already done that...
    – Rajat
    Feb 17, 2012 at 7:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.