WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to not have a menu on post pages. I think it would be something like "if page show menu, if post don't show menu" but I'm not sure how to put that into PHP.


share|improve this question
can you tell me which menu you want to hide wp_nav_menu(); or your custom menu? – Anjum Aug 23 '13 at 11:53
if (is_single()) {

you may pass a post id for any specific post for eg -

if (is_single('4')) {

will execute on post with id = 4 . hope it helps

share|improve this answer
prince what is if_single() it's is_single() or use if (is_single()) { // some code } – Anjum Aug 23 '13 at 11:49
oops i made mistake there thankyou for pointing out.. – pr1nc3 Aug 23 '13 at 11:51
Thanks, I understand it but I'm not sure how to write the don't show part? I have <nav><?php categories() ?></nav> – Nsokyi Aug 23 '13 at 11:59
if (!is_single()) { // show menus here.ie you wp_nav_menu() funtion...simple ? } – pr1nc3 Aug 23 '13 at 12:00
Ah, yes I think I have it working now I went with: <?php if( (is_single()) || (is_page('about')) || (is_page('contact') )) { ?> <style type=""> .cat_nav_wrap { display: none; } </style> <?php } ?> – Nsokyi Aug 23 '13 at 13:13

While you can use CSS to hide elements, I don't think it's ideal, especially for something like a menu. In effect, that element and its queries will still run and load (and therefore affect your page's speed), only to be hidden by the CSS.

I would recommend, instead, either editing your theme's header.php or creating a child theme with a new header.php file that conditionally loads the menu on pages that aren't single.php. In the TwentyThirteen theme, fr'ex, you would use the following in your header.php file:

  <?php if (is_singular()) :
        // DO NOTHING
  else : ?>
           <div id="navbar" class="navbar">
              <nav id="site-navigation" class="navigation main-navigation" role="navigation">
                 <h3 class="menu-toggle"><?php _e( 'Menu', 'twentythirteen' ); ?></h3>
                 <a class="screen-reader-text skip-link" href="#content" title="<?php esc_attr_e( 'Skip to content', 'twentythirteen' ); ?>"><?php _e( 'Skip to content', 'twentythirteen' ); ?></a>
                 <?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) ); ?>
                 <?php get_search_form(); ?>
              </nav><!-- #site-navigation -->
           </div><!-- #navbar -->
  <?php endif ?>
share|improve this answer
Wow, thanks for doing that. Your right that seems like a much better approach. Thank you. – Nsokyi Aug 24 '13 at 11:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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