Support » Fixing WordPress » How to hide the menu on a particular page?

  • I’m running on the default Twenty Eleven them, and I’d like to hide the navigation menu on a particular page, but still display my logo etc in the header.

    I expect I’d have to create a custom template to do so, but I’m unsure as to which file is the default template to modify – could anyone shed some light as to where I should start?


Viewing 7 replies - 1 through 7 (of 7 total)
  • you can create your own page template and use on page css like this

    .menuclass{ display:none;} (menuclass should be your class name)



    Forum Moderator

    for a css quick-fix, you could use the body_class() output of .page-id-123 (where 123 is the page ID) together with the css id of the menu, to hide the menu:


    .page-id-123 #access { display: none; }

    @santosh and @alchymyth – Thanks, but I’m still not sure where to start – you say ‘create your own page template’, but what do I base it on?

    If at all possible, I’d rather go down the custom template route so that I can simply select it in the future whenever I want a menu-less page. How would I go about this?



    Forum Moderator

    possibly start with a copy of page.php of your theme …

    as the menu is called in teh header.php, you will also need to edit that;

    once you know the file name of your page template (where you do not want to show the menu) you can use a conditional statement with is_page_template() to wrap the menu code;

    example (there is one new line before the <nav..> section, and one after):

    <?php if( !is_page_template('no-menu-page-template.php') : ?>
    			<nav id="access" role="navigation">
    				<h3 class="assistive-text"><?php _e( 'Main menu', 'twentyeleven' ); ?></h3>
    				<?php /* Allow screen readers / text browsers to skip the navigation menu and get right to the good stuff. */ ?>
    				<div class="skip-link"><a class="assistive-text" href="#content" title="<?php esc_attr_e( 'Skip to primary content', 'twentyeleven' ); ?>"><?php _e( 'Skip to primary content', 'twentyeleven' ); ?></a></div>
    				<div class="skip-link"><a class="assistive-text" href="#secondary" title="<?php esc_attr_e( 'Skip to secondary content', 'twentyeleven' ); ?>"><?php _e( 'Skip to secondary content', 'twentyeleven' ); ?></a></div>
    				<?php /* Our navigation menu. If one isn't filled out, wp_nav_menu falls back to wp_page_menu. The menu assigned to the primary location is the one used. If one isn't assigned, the menu with the lowest ID is used. */ ?>
    				<?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?>
    			</nav><!-- #access -->
    <?php endif; ?>

    this assumed that the new page template’s file name is ‘no-menu-page-template.php’

    @alchymyth That looks exactly like what I need! For some reason I’m getting a syntax errors on opening an closing though – do you have any idea why? I can’t see any reason why I would get one?

    Thanks for your help, I really do appreciate it!



    Forum Moderator

    I missed a bracket ;=(

    <?php if( !is_page_template('no-menu-page-template.php') ) : ?>


    Thank you so much, you are awesome! (:

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to hide the menu on a particular page?’ is closed to new replies.