Support » Fixing WordPress » how to hide menu on specific pages

  • Hello,

    I’m hoping someone can help me with my question.

    Is there a way to remove or hide a menu when a specific page is called up?

    I’ve already tried searching for help on this forum and via Google, but all I’ve been able to find are discussions about removing a page from displaying in a menu, so that’s not what I need.

    (1) I’ve tried wrapping my menu/navigation code between conditional tags, but I don’t know if I’m doing that right. I’ve used conditional tags before and successfully, so I don’t know if I’m doing something wrong this time around.

    (2) I can go and create a new page template and directly copy the header code minus the menu code into that new template. But I anticipate wanting to keep the menu hidden on other pages and page templates as well, not just on one specific page template.

    (3) I’ve tried creating a header02.php and calling that up, but that’s not working for me. Again, maybe I’m doing something wrong, but I can’t figure out what.

    So, is this even possible? And if so via conditional tags, could someone point me to a tutorial on how to use conditional tags to hide entire menus?

    Thanks sincerely for your help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Vaughan



    As you mention, using conditional tags is the answer. The simplest way is to use the is_page template tag in your sidebar file. For example, to omit the contents of the sidebar whenever the pages with IDs 2 and 14 are displayed, you’d have the following in sidebar.php:

    <?php if(is_page(array('2','14'))) { } else { ?>
     place original sidebar code here
    <?php } ?>

    Replace the IDs with the pages in question.

    Note though that the actual sidebar area will still be displayed because it will still be called from the page template. If you want neither the sidebar’s contents nor sidebar area to display, you’ll need to edit whichever template file runs get_sidebar with code similar to the above. If you have varying templates though and will be varying which pages will or won’t be displaying the sidebar though, there may be a lot of overhead with this latter method.

    Hope that helps.

    The method works OK. As for not displaying the empty column I put the code that calls different style sheet in the head of the document with the same method:

    <?php if(is_page(array(‘2′,’14’))) { ?>
    call to alternate style sheet
    <?php } else { ?>
    call to orig style sheet
    <?php } ?>

    I changed the width of the #content attribute.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘how to hide menu on specific pages’ is closed to new replies.