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 using calls to wp_nav_menu() in my header.php file. They're conditional, based on whether a user is logged in.

This is in header.php:

<?php if ( is_user_logged_in() ) :
        wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'user' ) ); 
else : 
        wp_nav_menu( array( 'container_class' => 'menu-header',  'theme_location' => 'visitor' ) );
endif; ?>

The menus are defined in functions.php:

add_action('init', 'menus_register');
function menus_register() {
   if ( function_exists( 'register_nav_menus' ) )
    register_nav_menus(array(
            'user' => __('Logged In'),
            'visitor' => __('Logged Out')
    ));
}

The menus are defined and assigned in the admin.

On every page, they work as I would expect them to, but not on the home page. On the home page, the correct container shows up, based on the condition, but the container is empty.

What would cause the same function call in header.php to return an empty container just on the home page?

-- edit --

Perhaps the menus_register() function in function.php is being called at the wrong time? Maybe there's some override in the theme that only applies to the homepage? I'm hoping folks with more experience can guide me in what to look for here.

share|improve this question
1  
No one can really help unless you post some code. –  songdogtech May 9 '12 at 14:45
    
Ok - code added –  Laizer May 9 '12 at 15:11
    
What Theme are you using? Can we see your header.php code and your index.php code? (Or front-page.php and/or home.php, if applicable?) Do you get anything returned for is_user_logged_in()? I would use $theme_location = ( is_user_logged_in() ? 'user' : 'visitor' ); print_r( $theme_location ); to test. –  Chip Bennett May 10 '12 at 12:26
    
I'm using birdsite - child themeing it. I am getting a result for is_user_logged_in() - the container for the menu is appearing in the code correctly (i.e. with the id of "menu-logged-out" or "menu-logged-in".) The relevant part of index.html is simple as can be: <?php get_header(); ?> –  Laizer May 10 '12 at 14:15
    
No love, huh? seems something of a mystery. –  Laizer May 15 '12 at 17:24
show 1 more comment

1 Answer

up vote 0 down vote accepted

It looks like this behavior is the result of adding custom post types to the query.

See http://wordpress.org/support/topic/wp-nav-menu-dissapears-in-category-pages-1

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.