Skip to main content

I have the following code to show different menus to logged in members. I would like to add two total menusa second menu to be displayed when logged in, for a total of 3 menus, as there are two different menu areas for logged-in users.

function my_wp_nav_menu_args( $args = '' ) {
if( is_user_logged_in() ) {

$args['menu'] = 'menu-1';

} else {

$args['menu'], $args['menu'] = 'menu-3';
}
return $args;
}
add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' );

When using this code as-is, "menu-1" will display twice in the 2 areas. I can not figure out the syntax to add another menu line to include "menu-2". Can someone let me know what to change?

I have the following code to show different menus to logged in members. I would like to add two total menus to be displayed when logged in, as there are two different menu areas for logged-in users.

function my_wp_nav_menu_args( $args = '' ) {
if( is_user_logged_in() ) {

$args['menu'] = 'menu-1';

} else {

$args['menu'], $args['menu'] = 'menu-3';
}
return $args;
}
add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' );

When using this code as-is, "menu-1" will display twice in the 2 areas. I can not figure out the syntax to add another menu line. Can someone let me know what to change?

I have the following code to show different menus to logged in members. I would like to add a second menu to be displayed when logged in, for a total of 3 menus, as there are two different menu areas for logged-in users.

function my_wp_nav_menu_args( $args = '' ) {
if( is_user_logged_in() ) {

$args['menu'] = 'menu-1';

} else {

$args['menu'], $args['menu'] = 'menu-3';
}
return $args;
}
add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' );

When using this code as-is, "menu-1" will display twice in the 2 areas. I can not figure out the syntax to add another line to include "menu-2". Can someone let me know what to change?

Source Link

How to add more than one menu for logged in members?

I have the following code to show different menus to logged in members. I would like to add two total menus to be displayed when logged in, as there are two different menu areas for logged-in users.

function my_wp_nav_menu_args( $args = '' ) {
if( is_user_logged_in() ) {

$args['menu'] = 'menu-1';

} else {

$args['menu'], $args['menu'] = 'menu-3';
}
return $args;
}
add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' );

When using this code as-is, "menu-1" will display twice in the 2 areas. I can not figure out the syntax to add another menu line. Can someone let me know what to change?