Tagged: yigit
I have created this simple function to show a different menu when not logged in:
// set correct menu
function display_correct_menu($args = '') {
if ( !is_user_logged_in() ) {$args['menu'] = 'top-not-logged-in';} else {$args['menu'] = 'top';}
return $args;
}
add_filter( 'wp_nav_menu_args', 'display_correct_menu' );
Unfortunately, the dropdown for WPML language choice disappears when using this. Perhaps there is a better way. Perhaps you can provide a solution.
Thanks!
I created a ticket with WPML support. I welcome your ideas if you have any, but this is probably something they need to look at. Thanks so much for the help!
This was solved by WPML support. Here it is:
// set correct menu
function display_correct_menu($args = '') {
if ( !is_user_logged_in() ) { $args['menu'] = wp_get_nav_menu_object( 'top-not-logged-in' ); }
else { $args['menu'] = wp_get_nav_menu_object( 'top' ); }
return $args;
}
add_filter( 'wp_nav_menu_args', 'display_correct_menu' );