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 found this code from Different Main Navigation per category:

<?php
  if(is_category('first-category') || in_category('first-category)) { 
wp_nav_menu( array('menu' => 'First Category Nav' )); 
} else {
  wp_nav_menu( array('menu' => 'Default Nav' ));
}
?>

and want to re-use this to display different main nav in my home.php and the rest of the page.

I came up with this:

<?php
if(is_page('???') || in_page('???')) { 
  wp_nav_menu( array(
   'menu' => 'Main Nav Menu',
   'container' => ''
  )); 
} else {
  wp_nav_menu( array(
    'menu' => 'Nav Menu',
    'container' => ''
  ));
}
?>

but I don't know where to find this home.php slug, I tried 'home' as slug but i turned out an error page:

Fatal error: Call to undefined function in_page() in D:\xampp\htdocs\wp-xxx\wp-content\themes\BLANK-Theme\header.php on line 62
share|improve this question
add comment

1 Answer

Use is_home() for the home page (the list of newest blog posts), and is_front_page() for the front page (can be a static page too).

if( is_home() ) 
{ 
    wp_nav_menu( 
        array(
            'menu'      => 'Main Nav Menu',
            'container' => ''
        )
    );
}
share|improve this answer
    
Hi Thank you, can you show me the code? e.g. below, how am I gonna put it? <?php if(is_home() || in_page('???')) { ... } –  Lizza Faith Apr 2 '13 at 4:10
    
@LizzaFaith See my update. –  toscho Apr 2 '13 at 4:15
    
thanks, it worked, I can have different main menu in different page –  Lizza Faith Apr 2 '13 at 4:25
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.