Display Different WordPress Menu to Logged in Users

Screenshot of an online bookstore homepage with a green header, navigation menu, and banner advertising “Sales up to 70% off.” Different Wordpress menus are visible at the top, and three book covers are displayed to the right.

When creating a WordPress website you may run into scenarios where you would like to display different WordPress menus depending on if a WordPress User is Logged In or Logged Out.

For example. you may have a WordPress membership site and you would like to display different WordPress menus to your logged in users. In this blog, we will show you how to how to show different WordPress menus to logged in users in WordPress.

Creating the new WordPress Menus

In WordPress even if your theme has one menu location, you can still create multiple WordPress menus for the same location.

Go to Appearance > Menus, create two menus logged-in and logged-out.

Wordpress Tutorial: Display Different WordPress Menus to Logged in Users
				
					// Conditional Nav Menu

function wpc_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', 'wpc_wp_nav_menu_args' );
				
			
If you’re trying to target a specific menu location created by your theme, you can use the following:
				
					// Conditional Nav Menu

function wpc_wp_nav_menu_args( $args = '' ) {
if( is_user_logged_in()) { 
  	if( 'top-navigation' == $args['theme_location'] ) { // Change top-navigation to theme specific name
	    $args['menu'] = 'logged-in';
	}
} else { 
	if( 'top-navigation' == $args['theme_location'] ) { // Change top-navigation to theme specific name
	    $args['menu'] = 'logged-out';
	}
} 
    return $args;
}
add_filter( 'wp_nav_menu_args', 'wpc_wp_nav_menu_args' );
				
			

In Summary

That’s all you will see that your logged in visitors will see the logged-in menu and the non-registered or logged out users will see a different menu. This method allows you to create two different menus for your users so that you can freely update your menus for logged in or logged our users. We hope this blog topic helps you show different menus to logged in users in your WordPress site. For questions please leave a comment below.

Table of Contents

Looking for more?

Here are some other articles that we think you will be interested in!

Screenshot of the Elementor page builder interface, with a drag-and-drop sidebar on the left and a web page preview on the right. A logo sits centerstage, set against a pink and purple gradient—perfect for adding PHP Code to Elementor projects.

How To Add PHP Code to Elementor

In this tutorial, we are going to show you how to easily add PHP Code to any Elementor page by creating a simple shortcode and adding it to your functions.php

Screenshot showing a webpage with food listings and a pop-up form titled Listing Settings, where a restaurant listing is being edited. Three food-related cards are visible, displayed in a layout created with WPBakery Visual Composer.

Create A WPBakery Visual Composer Add-On

Learn how easy it is to create a WPBakery Visual Composer Add-on element that you can use for almost any application! This can come in handy when you’re building a website for a client that isn’t so tech savy, but would like to be able to make some changes on their own in the future. Click the link to get started: