How to Show Different Menus to Logged In Users in WordPress

Do you want to show different menus to logged in users in WordPress?

By default, WordPress allows you to display the same navigation menu in a specific location in your theme. But what if you want to display a different menu for logged-in users on your website?

In this article, we will show you how to easily display different menus to logged in users in WordPress.

Displaying different navigation menus for logged in and non-logged in users in WordPress

Why show different menus to logged in users in WordPress?

Changing the different areas of your WordPress website based on your visitors and their activity makes your site personalized for each user.

This personalized content helps you improve the user experience on your WordPress site.

Now, if you’re running a website where users don’t need to register or login, you can probably use the same navigation menus on your website.

However, other websites can greatly benefit from displaying personalized menus to logged-in users.

For example, websites like an online store, a community of WordPress membership sites, or an e-learning platform can all benefit from custom navigation menus.

A personalized navigation menu for logged in users helps them find the items they subscribed to more easily.

For example, a user of an online store can manage their account, or a member of a paid community can easily renew their subscription or view the online courses they have purchased.

By default, WordPress lets you create as many navigation menus as you want. However, you can only choose to display one menu at a particular location in your WordPress theme.

That being said, let’s take a look at how to easily change this behavior and show different menus to logged in users in WordPress.

Creating menus for logged in and non logged in users in WordPress

Whichever method you use, you must first create the two navigation menus you want to display for your logged in and logged out users.

Just head to the Appearance ยป Menus page in the WordPress dashboard. If you already have a navigation menu that you use on your website for all users, this might be your default menu.

Main Menu

After that, click on the “Create a new menu” link to create a new custom menu for your logged in users.

Here you can add menu items that you want to show to registered or logged in users. For example, you can add a logout link to your menu.

On the left side of the screen, you can see a list of your website pages. Simply check the box next to the page you want to add to your menu and click the “Add to Menu” button.

Connected menu

You can also drag and drop menu items on the right side of the screen to rearrange them.

Further down the page, you can choose a location to display your menu. But, you don’t need to assign a location to this menu now. We will do that later in the article.

Don’t forget to click the “Save Menu” button to save your changes.

For more details on creating menus, see our beginner’s guide to WordPress navigation menus.

Method 1. Display different menus for logged in users in WordPress using a plugin

This method is easier and recommended for all WordPress users.

First, you need to install and activate the Conditional menus connect. For more details, see our step-by-step guide on how to install a WordPress plugin.

Upon activation, you must visit the Appearance ยป Menus page and switch to the “Manage Locations” tab.

From there, you will see the list of available menu locations defined in your WordPress theme and the menus that are currently showing.

Manage menu locations

For example, it shows that our main menu location displays a navigation menu titled “Main Menu”.

Now we need to tell the plugin to show a different menu when a certain condition is met.

To do this, click on the “+ Conditional menu” link, then select the navigation menu you want to show to logged-in users from the drop-down menu.

Select the connected menu

Next, you need to click on the ‘+ Conditions’ link.

This will bring up a pop-up where you’ll see a bunch of conditions to choose from.

Select logged in user as condition

Simply check the box next to the “Logged in user” option, then click the save button.

You can now visit your website to see the logged in user menu in action. You can also log out of your WordPress admin to view the navigation menu that will be displayed to all other users.

Different menu for logged in users

Method 2. Manually Select Connected Menu in WordPress Using Code

This method requires you to add code to your WordPress website. If you haven’t already, check out our guide on how to copy and paste snippets in WordPress.

First, you need to add the following code to your theme’s functions.php file or a site-specific plugin.

function my_wp_nav_menu_args( $args="" ) {
if( is_user_logged_in() ) {
// Logged in menu to display
$args['menu'] = 43;

} else {
// Non-logged-in menu to display
$args['menu'] = 35;
return $args;
add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' );

Be sure to replace 43 and 35 with the IDs of the navigation menus you created earlier.

You can find the ID of a navigation menu by selecting it on the Menus page. You will see the menu ID number in your browser’s address bar.

Find Navigation Menu ID

We hope this article helped you learn how to easily display different navigation menus to logged in users in WordPress.

You can also check out our guide on how to get a free email domain, or check out our roundup of the best business phone services for small businesses.

If you liked this article, subscribe to our Youtube channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

The post How to Show Different Menus to Logged In Users in WordPress first appeared on WPBeginner.

Leave a Comment

Your email address will not be published.