Hi,
I tried to add login / logout links to the mobile menu, and cannot make this work. It works when the user is logged in, but doesn’t work if he’s loggewd out – in that case the filter isn’t even triggering. Here’s my code:
/**
* Add login / logout link to the menu
*/
add_filter( 'wp_nav_menu_items', 'bs_login_logout_link', 10, 2 );
function bs_login_logout_link( $items, $args ) {
var_dump($args);
if( $args->theme_location == 'mobile_menu' ) {
$loginoutlink = wp_loginout( 'index.php', false );
$items .= '<li class="menu-item menu-item-type-post_type menu-item-object-page">'. $loginoutlink .'</li>';
return $items;
}
return $items;
}
Any ideas?
Thanks