Tagged: menu
Hi,
I’m trying to use the code below to display different Main Menu and Mobile Burger Menu’s depending on if the user is logged in or not.
I’ve searched through the enfold theme files but can’t find what the menu location names are. I’ve used top-navigation
and mobile-menu
as placeholders here.
Thanks in advance,
Luke
function f421_wp_nav_menu_args( $args = '' ) {
if( is_user_logged_in()) {
if( 'top-navigation' == $args['theme_location'] ) {
$args['menu'] = 'main-menu-logged-in';
}
} else {
if( 'top-navigation' == $args['theme_location'] ) {
$args['menu'] = 'main-menu-logged-out';
}
}
return $args;
}
add_filter( 'wp_nav_menu_args', 'f421_wp_nav_menu_args' );
function f422_wp_nav_menu_args( $args = '' ) {
if( is_user_logged_in()) {
if( 'mobile-menu' == $args['theme_location'] ) {
$args['menu'] = 'mobile-menu-logged-in';
}
} else {
if( 'mobile-menu' == $args['theme_location'] ) {
$args['menu'] = 'mobile-menu-logged-out';
}
}
return $args;
}
add_filter( 'wp_nav_menu_args', 'f422_wp_nav_menu_args' );
Hey LukeHopkins,
You can have a look at this file /includes/helper-main-menu.php, it has hooks and filters for the main menu.
Best regards,
Victoria