I want to hide an item from a menu if a user is logged out.
I am currently using the below code that achieves this using two separate menus, but to save duplication, I would like to only have to manage one nav menu.
function my_wp_nav_menu_args( $args="" ) {
if ( is_user_logged_in() ) {
$args['menu'] = 'logged-in';
} else {
$args['menu'] = 'logged-out';
}
return $args;
}
add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' );
Is it possible to hide just one item for a logged out user, rather than doing it the way I currently am?