Have you ever wanted your WordPress menu to be more intelligent? Perhaps you want to provide unique navigation options for logged-in users or show specific menu items only on certain pages.
Out of the box, WordPress presents the same static menu to every visitor, which can make your site feel bland and uninviting. Many website owners we’ve collaborated with have encountered this very issue.
Fortunately, implementing conditional menus can significantly enhance your user experience.
When your WordPress navigation adjusts to different users and situations, visitors can locate what they need more quickly. This also allows you to steer them towards the actions that are most important for your business.
In this guide, we will explain how to incorporate conditional logic into your WordPress menus. You will discover how to create dynamic navigation that varies based on user roles, specific pages, or any other criteria you decide.
Why Implement Conditional Logic in WordPress Menus?
Navigation menus provide structure to your website and assist visitors in finding what they are searching for.
By default, your WordPress site will show the same navigation menu to all users across all posts and pages.
However, there may be instances when you want to present different menus to various users or on different pages of your website.
By utilizing conditional logic, you can enhance your WordPress menus to create personalized experiences for logged-in users. Here are some examples of how this can be applied across various types of websites:
- E-commerce website – Feature products or promotions tailored to a customer’s browsing or purchase history.
- Membership website – Provide access to exclusive pages and resources solely for logged-in members.
- Online education platform – Present different course categories or lessons based on a student’s progress.
Think of it as controlling access to WordPress menus. 💡
With this in mind, we will guide you through the process of adding conditional logic to your WordPress menus. The following topics will be covered in this tutorial:
- Creating New Navigation Menus in WordPress
- Displaying a Different Menu for Logged-In Users in WordPress
- Displaying a Different Menu for Logged-In Users Using Full Site Editing
- Displaying a Different WordPress Menu Based on User Role
- Displaying a Different Menu for Various Pages in WordPress
- Hiding the Navigation Menu on Landing Pages in WordPress
- Common Questions About Conditional Menus
- Further Reading: Enhancing Your WordPress Navigation Menus
Are you ready? Let’s begin.
How to Create New Navigation Menus in WordPress
Start by creating the additional navigation menus you want to showcase in WordPress. After that, you can implement conditional logic to determine when each menu will appear.
In the following sections, we will guide you on how to incorporate conditional menus into WordPress using both the classic and block editors.
How to Create New Navigation Menus in WordPress with the Classic Editor
This approach is suitable for users of classic themes.
To create new navigation menus, simply navigate to theAppearance » Menussection in the WordPress dashboard. If you already have a navigation menu that serves all users on your website, you can set this as your default menu.
Next, click on the ‘create a new menu’ link to set up a new menu item. For instance, you might create one menu for logged-in users and another for specific WordPress pages or categories.
On the left side of the screen, you’ll find a list of your website’s pages. Just check the box next to any page you want to include in your menu and click the ‘Add to Menu’ button.
You can also rearrange the menu items on the right side of the screen by dragging and dropping them.
Scroll down the page to select a location for your menu display. However, you don’t need to assign a location to this menu just yet; we will handle that in the next step.
Remember to click the ‘Save Menu’ button to ensure your changes are saved.
For additional information on creating menus, check out our beginner’s guide on how to add a navigation menu in WordPress.
Creating New Navigation Menus in WordPress with Full Site Editing
To create new navigation menus in a block theme using Full Site Editing (FSE), start by navigating toAppearance » Editorin your WordPress dashboard.
Once you’re in the editor, click the ‘Navigation’ tab to expand it. For reference, we are using the Twenty Twenty-Three theme in this guide.
Next, click ‘Edit’ next to the ‘Navigation’ label.
This action will open the full site editor on your screen.
From here, simply click the ‘+’ icon to add a navigation menu item. A prompt will appear with a dropdown menu for you to choose an option.
For more comprehensive instructions, refer to our guide on how to add a navigation menu in WordPress.
Displaying a Different Menu for Logged-In Users in WordPress
Displaying different navigation menus based on user login status can enhance the user experience on your WordPress site.
For instance, you can add login and registration links for users who are not logged in, while providing a logout link for those who are logged in.
If you operate a WooCommerce store, you can showcase products specifically for your customers that are not visible to the general public.
How to Display a Unique Menu for Logged-In Users Using the Classic Editor
To begin, install and activate the Conditional Menus plugin. For detailed instructions, refer to our comprehensive guide on installing a WordPress plugin.
After activation, navigate toAppearance » Menusand select the ‘Manage Locations’ tab.
Here, you will find a list of available menu locations along with the menus currently in use, which may differ based on your chosen WordPress theme.
For example, on our demo site, the ‘Primary Menu’ location is currently displaying a navigation menu labeled ‘Main Menu’.
You can instruct the plugin to display a different menu when specific conditions are met by clicking on the ‘+ Conditional Menu’ link and selecting an alternative menu from the dropdown.
In this tutorial, we will choose the ‘Logged in Menu’ option.
Next, click on the ‘+ Conditions’ link.
A popup will appear displaying various conditions to select from.
Simply check the box next to the ‘User logged in’ option, and then click the ‘Save’ button.
You can now visit your website to see the logged-in user menu in action. Log out to view the navigation menu available to all other users.
For more detailed instructions and to learn how to achieve this using code, check out our guide on displaying different menus for logged-in users in WordPress.
Displaying a Unique Menu for Logged-In Users with Full Site Editing
If you’re using a block theme, you’ll need to install the Conditional Blocks plugin. Let’s start by installing and activating the plugin. For assistance, refer to our guide on how to install a WordPress plugin.
Once activated, you can access the Full Site Editing feature by going to Appearance » Editor.Then, click on ‘Patterns’ followed by ‘All template parts.’
You should now see all your template parts, which may include a footer, header, and comments. Click the three dots in the ‘Header’ section and select ‘Edit.’
This will take you to the block editor.
Next, click on the navigation menu block to add conditional logic.
Then, switch to the ‘Block’ tab in the right-hand panel to begin customization.
Scroll down in the ‘Block’ tab to find the ‘Conditional Blocks’ section. Click on it to access customization options.
Next, click the ‘Edit Visibility’ button.
A pop-up window will appear, allowing you to set conditions for your selected navigation menu.
Here, open the ‘CONDITION’ dropdown and choose the ‘User Logged In’ option.
Close the window by clicking the ‘X’ button in the top right corner.
You should see a condition added to the ‘Conditional Blocks’ section. Click ‘Save’ to update your navigation menus.
Now, when you visit your website, here’s how it may appear for logged-out and logged-in users:
Displaying a Different WordPress Menu Based on User Role
Once a user logs in, you can show a different navigation menu based on their assigned user role.
For instance, you can add additional menu items for administrators while providing limited options for contributors. On a membership site, you can assign varying access levels based on different membership tiers.
Displaying a Unique WordPress Menu Based on User Role with the Classic Editor
As mentioned earlier, you’ll need to install and activate the Conditional Menus plugin.
Next, navigate to the Appearance » Menus section and select the ‘Manage Locations’ tab.
You should assign the appropriate conditional menu for the chosen user role. In this tutorial, we will choose the ‘Nav Menu Administrator’ menu.
After that, click the ‘+ Conditions’ link to select the user role.
You will need to click on the ‘User Roles’ tab to view checkboxes for each user role on your website. Simply select the user roles that will have access to this menu, then click the ‘Save’ button to apply your changes.
Displaying a Unique WordPress Menu Based on User Role with Full Site Editing (FSE)
To display a different menu based on user roles in FSE, you will utilize the Content Control plugin. If you need assistance with installation and activation, please refer to our guide on installing a WordPress plugin.
Once activated, you can go to Appearance » Editor» Patterns » All Template PartsNext, click the three dots in the ‘Header’ section and select ‘Edit.’
In the editor, choose a navigation menu to apply conditional logic.
For instance, we will configure our ‘Blog’ page to be accessible only to subscribers. Click ‘Blog’ to access its customization settings.
Now, navigate to the right-hand panel and toggle the ‘Enable Controls’ switch under the ‘Block Controls’ section.
Scroll down to the ‘User Rules’ section to establish the conditions.
First, open the ‘WHO CAN SEE THIS CONTENT’ dropdown menu and select ‘Logged In User.’
For the ‘USER ROLE’ dropdown, select ‘Matching.’ In the ‘CHOSEN ROLES,’ choose ‘subscriber.’
Once you have completed the setup, click the ‘Save’ button.
Displaying Different Menus for Various Pages in WordPress
You can show different menus for different pages in WordPress.
For example, you might want to add additional menu items on your privacy policy page, such as a link to your cookie notice.
Displaying Different Menus for Various Pages in WordPress Using the Classic Editor
Begin by installing and activating the Conditional Menus plugin. Next, navigate to Appearance » Menus»Manage Locations.
Select the desired navigation menu and click the ‘+ Conditions’ link. Then, navigate to the ‘Pages’ tab, where you will find a complete list of all the pages on your site.
Mark each page where you want the navigation menu to appear by checking the box next to it. After you finish, click the ‘Save’ button.
Displaying Different Menus for Various Pages in WordPress Using FSE
Users of block themes can utilize the Block Visibility plugin. For installation assistance, please refer to our guide on how to install a WordPress plugin.
Once activated, go to Appearance » Editor» Patterns » All template parts. After opening the Header editor, navigate to the ‘Visibility’ section.
From this section, open the dropdown menu and select ‘URL Path.’
Next, enter the URL path for the Privacy Policy page in the ‘URL PATH (CONTAIN)’ field.
A URL path refers to the segment of a web address that follows the main domain name, directing users to a specific page or item.
For instance, in the URLhttps://example.com/about, the /about segment represents the URL path.
If you’re unsure of the URL path for your Privacy Policy page, navigate to Pages » All Pages. Locate the Privacy Policy page and hover over it.
Click the ‘Quick Edit’ button, and look for the ‘Slug’ section. The URL path will start with the ‘/’ symbol followed by the page’s slug.
Alternatively, you can visit the page and copy the portion that comes after the domain name.
That’s all! Click ‘Save’ to apply your changes.
Hiding the Navigation Menu on Landing Pages in WordPress
There are instances on your website where you might want to hide the navigation menu entirely, such as on landing pages.
A landing page is specifically designed to boost sales or generate leads for a business. On these pages, it’s essential to minimize distractions and provide users with all the necessary information to encourage a specific action.
In our guide on boosting your landing page conversions by 300%, we recommend reducing distractions by eliminating navigation menus and other links from the page.
How to Hide the Navigation Menu on Landing Pages in WordPress Using the Classic Editor
You can achieve this by using the Conditional Menus plugin. Select ‘Disable Menu’ from the dropdown menu when setting up the conditional menu.
Next, click the ‘+ Conditions’ link to specify when the menu should be displayed.
Click on the ‘Pages’ tab and check the box next to ‘My Landing Page’.
Remember to click the ‘Save’ button to save and apply your changes.
How to Hide the Navigation Menu on Landing Pages in WordPress Using Full Site Editing
For users of block themes, you can utilize the Block Visibility plugin. Enter the URL path in the ‘URL Path (Does Not Contain)’ field.
Let’s install and activate the plugin. If you need assistance, feel free to check our guide on installing a WordPress plugin.
After activation, navigate toAppearance » Editor» Patterns » All Template Parts. In the Header editor, locate the ‘Visibility’ section.
Here, select ‘URL Path’ and input the path of your landing page in the ‘URL Path (Does Not Contain)’ field.
Once finished, simply click the ‘Save’ button.
Common Questions About Conditional Menus
Do you have questions about configuring or personalizing conditional menus in WordPress? Here are some quick answers to assist you in getting started.
What is the top conditional menu plugin for WordPress?
For those using a classic theme, the Conditional Menus plugin is an easy and dependable option. If you’re using block themes, tools like Conditional Blocks or Block Visibility provide robust control directly within the editor.
Is it possible to add conditional logic to menus without using a plugin?
Yes, it is possible, but it requires adding custom code to your theme’s files, which is recommended only for advanced users since even a minor error can disrupt your site.
For most users, a plugin like WPCode offers a much safer and simpler method to add and manage code snippets. You can learn all about it in our comprehensive WPCode review.
Can I set conditions for a single menu item rather than the entire menu?
Yes, indeed. Many contemporary WordPress themes and menu plugins support this feature. In the classic menu editor (Appearance » Menus), you can often establish visibility rules for individual items. In the block editor, you can set conditions for specific navigation link blocks.
Additional Reading: Enhancing Your WordPress Navigation Menus
Navigation menus serve as essential tools in web design, enabling you to guide visitors to the key areas of your WordPress blog or website.
After successfully displaying different navigation menus on various pages and for distinct user roles, you might be curious about further customization options.
To enhance the capabilities of your navigation menus, explore these helpful tutorials:
- How to Add Custom Items to Specific WordPress Menus
- How to Create Custom Navigation Menus in WordPress Themes
- How to Implement a Fullscreen Responsive Menu in WordPress
- How to Design a Vertical Navigation Menu in WordPress
- How to Integrate a Mega Menu into Your WordPress Site
- How to Style WordPress Navigation Menus Effectively
- How to Show Breadcrumb Navigation Links in WordPress
If you enjoyed this article, consider subscribing to our YouTube Channel for WordPress video tutorials. You can also connect with us on Twitter and Facebook.



