Based on @jamio answer I agree that if you just `display:none` the menu its still accessible thru `inspect element`, therefore I come up with the solution that if you want to hide the nav menus based on their class you can use `classes[0] ` instead of `title` so that you can now just add a class on menu instead on setting each menu thru code add_filter( 'wp_nav_menu_objects', 'remove_menu_items', 10, 2 ); function remove_menu_items( $items, $args ) { $logged_in = is_user_logged_in(); foreach ( $items as $item_index => $item ) { // Remove menu item with "hide_when_logout" class when not logged in if ( $item->classes[0] == 'hide_when_logout' ) { if ( !$logged_in ) { unset($items[$item_index]); } } } return $items; }