I've got a script that works.... a bit too well. It's supposed to be when you login to the site, the main nav reflects that switch. It works, but it's only supposed to occur on the nav in the header. Instead, it changes all nav elements, no matter where they are. So I have three other menus in the footer but they all change to the same menu.
How can I just target the main nav in my header alone?
Here's the code:
function my_wp_nav_menu_args( $args = '' ) {
if( is_user_logged_in() ) {
// Logged in menu to display
$args['menu'] = 80;
} else {
// Non-logged-in menu to display
$args['menu'] = 25;
}
return $args;
}
add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' );