Steps To Create Logged in and Non-Logged in Primary Menu
- Create two new menus "Public-Menu" & "Private-Menu"
- Assign assign menu items for both menu
- Make "Public-Menu" as primary menu
- Add below code in theme function.php file
// Conditional Nav Menu function wpexpertsin_menu_args( $args = '' ) { if( is_user_logged_in()) { if( 'primary-menu' == $args['theme_location'] ) { $args['menu'] = 'Private-Menu'; } } else { if( 'primary-menu' == $args['theme_location'] ) { $args['menu'] = 'Public-Menu'; } } return $args; } add_filter( 'wp_nav_menu_args', 'wpexpertsin_menu_args' );
- Save the file
- All done!