treehouse : what would you like to learn today?
Web Design Web Development iOS Development

hide sidebar in wordpress

  • I want to be able to hide the side bar on some pages. I don't think this is correct, this is the basic idea...
    Can we use the word 'hide' like 'get'....what's the proper syntax


    <?php if(is_page('marketplace')): ?> 
    <?php hide_sidebar(); ?>
    <? endif; ?>
  • That won't exactly work... Wordpress doesn't really have hide functionality like that.

    Actually, you might want to think about this in a slightly different way:

    <?php if (!ispage('marketplace')) { get_sidebar(); } ?>


    What this code does is check if the current page is not the marketplace page (the "!" indicates not) and then displays the sidebar. You could also do this with multiple pages:

    <?php if (!ispage('marketplace') && !ispage('page2') && !ispage('page3')) { get_sidebar(); } ?>


    The "||" in the if statement indicates "and", so this reads "if the page is not marketplace, and it isn't page2, and it isn't page3, show the sidebar. If it is one of these pages, the sidebar won't be shown.