0

I'm trying to change the header menu, such that it looks different when it is logged in and logged out, without changing the main menu.

function my_wp_nav_menu_args( $args = '' ) {
    if( is_user_logged_in() ) { 
        $args['widget_nav_menu'] = 'menu 4';
    } else { 
        $args['widget_nav_menu'] = 'menu 3';
    } 
    return $args;
}
add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' );

This does the job to change the header menu, but it also changes the main menu. How do I get it to not change the main menu?

  • Anyone have any ideas? Please help! – user71292 Apr 28 '15 at 2:48
0

You should add a class to the header when the user is logged in, this way, only your css would have to change.

You can do it like this in your header.php file :

<header class="header clear <?php echo ((is_user_logged_in())?'logged-in-header':'not-logged-in-header'); ?>" role="banner">

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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