Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm building a landing page and want to remove the navigation menu from the page. The navigation menu is in header.php which is of course in the page template. Is there a WordPress function I can use to remove the navigation menu from this specific page? I know I could do it with jQuery and do display:none for the nav menu but i'd like to do it server side before the page loads.

Thanks

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

Use a conditional tag:

Codex References:

Function Reference (is_page)

Function Reference (Conditional Tags)

You can specify the landing page by Page ID, Page Title or Page Slug.

Here is an example:

<?php if ( !is_page( 'landing-page' ) ) { 
  wp_nav_menu( array( 
    'show_home' => 'Home', 
    'container' => 'false', 
    'theme_location' => 'main') 
    ); 
  }
  endif;
  ?>

It excludes the page (in this case the page with the slug "landing-page") by placing the ! in front of is_page

No need for javascript, this should do the trick.

share|improve this answer
add comment

I just answered on a duplicate question, but another solution is to filter wp_nav_menu.

Conditional logic will probably work as long as you haven't messed around with the query object and forgot to reset it.

function wpa76334_filter_nav_menu($menu, $args){
    if( is_page_template('your-template.php')) $menu = null; //use your own conditions
    return $menu;
}
add_filter('wp_nav_menu','wpa76334_filter_nav_menu', 10, 2);
share|improve this answer
add comment

Your Answer

 
discard

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.