Tagged: secondary menu
I know the code below is for changing the main menu for the login user.
Could you tell me the code for changing the secondary menu for login user?
/*Display a different menu for registered users*/
add_filter( ‘wp_nav_menu_args’, ‘my_wp_nav_menu_args’ );
function my_wp_nav_menu_args( $args = ” ) {
if($args[‘theme_location’] === ‘avia’)
if( is_user_logged_in() ) {
$args[‘menu’] = ‘THE NAME OF YOUR LOGGED IN MENU HERE’;
} else {
$args[‘menu’] = ‘THE NAME OF YOUR LOGGED OUT MENU HERE’;
}
return $args;
}
Hey,
Please use the code as following
/*
Display a different menu for registered users
*/
add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' );
function my_wp_nav_menu_args( $args = '' ) {
if($args['theme_location'] === 'avia3')
if( is_user_logged_in() ) {
$args['menu'] = 'THE NAME OF YOUR LOGGED IN MENU HERE';
} else {
$args['menu'] = 'THE NAME OF YOUR LOGGED OUT MENU HERE';
}
return $args;
}
Best regards,
Yigit
It looks like “avia3” is not for the secondary menu
When I change ‘avia3’ to ‘avia2’, it works.
Thanks!