Hide pages in nav if not logged in?
-
Been searching for over an hour for a solution to this & ended up back here.
I’ve created a special admin page for logged-in users. I’d like this page to be available / visible in the standard wp horiz menu, but only if you are logged in.
I’ve tried to creating 2 different custom menus & switching between them with this, but it’s not working. Any ideas or alternative suggestions most welcome – Thanks
add_filter('wp_nav_menu_objects', 'members_menu', 10, 2); function members_menu($sorted_menu_items, $args) { if ($args->theme_location == 'Primary' && is_user_logged_in()){ $header_members_items = wp_get_nav_menu_items('Header_members'); _wp_menu_item_classes_by_context( $header_members_items ); foreach ($header_members_items as $item) { $sorted_menu_items[]=$item; } } return $sorted_menu_items; }
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Hide pages in nav if not logged in?’ is closed to new replies.