Notice: These forums are now retired and closed. For active support, please Submit a Ticket or visit our official WordPress.org community pages.
Kadence Theme | Kadence Blocks | Starter Templates | WooCommerce Email Designer | Ascend | Virtue | Pinnacle

Menu based on login/logout

Home / Forums / Virtue Theme / Menu based on login/logout

This topic is: Resolved
[Resolved]
Posted in: Virtue Theme
September 13, 2015 at 7:51 pm

Hi,

I wanted to change the Top Menu based on whether the user has logged in or logged out. I have used the code below in my child theme functions.php. I do not see any error but the menu does not change. Am I using the “Top Navigation” menu label correctly ?

Thanks

/**
* Change top bar menu based on whether the user is logged-in or logged-out
*/

function my_wp_nav_menu_args( $args = ” ) {

if( is_user_logged_in() ) {
$args[‘Topbar Navigation’] = ‘logged-in’;
} else {
$args[‘Topbar Navigation’] = ‘logged-out’;
}
return $args;
}
add_filter( ‘wp_nav_menu_args’, ‘my_wp_nav_menu_args’ );

  • The forum ‘Virtue Theme’ is closed to new topics and replies.