How to Show or Hide Menu Items on Certain Conditions in WordPress

Share this

menu items WordPress

Every website has navigation menu items. They help webmasters to divert visitors to certain category related posts or pages in the site. The items are common in most of the cases. It means, everyone who is engaged with the site will see the same menu irrespective of their user roles and pages opened.

How to show different menus based on the user roles, pages and device type in WordPress?

Do you want to show some menu items to logged in users only and hide them from normal visitors of the site?

We’ll show you how to do that. You have to apply certain conditions to manage menu items in WordPress.

Show and hide menu items in a WordPress site

Sign into your WordPress site, open Plugins menu from the left sidebar and tap Add New button. Search for If Menu plugin.

menu items WordPress

Install and activate the plugin.

Go to Appearance and Menus to customize your menu items. Open each item in the menu structure to view the plugin tools.

Check Enable conditional logic box to configure the item appearance.

menu items WordPress

Choose Show or hide from the first drop-down box. It instructs the plugin to show/hide the chosen menu item if the following conditions are matched. Set your condition in the next box.

menu items WordPress

If Menu lets you customize the menu based on the user roles, page types and devices. Choose your primary condition and if you want to use it with the combination of another, select And or Or from the third box. The next line of conditions will be added automatically. Fill them. Repeat these steps for all menu items and Save.

If Menu is highly flexible, easy to use and can be used to manage menus in several ways. You can create so many items as you want and arrange them across different page types or according to the own custom conditions opted.

Nav Menu Roles is another popular plugin to hide menu items based on user roles. So you can show some items to certain users only and hide the same from others as well.

After installing, go to Menus to manage item visibility. Set Display mode for each item regardless of reader’s role on the site. Show it for all users or just logged in/logged out users.

menu items WordPress

For deeper customization, go to next option where you can restrict the item according to the minimum user roles. The plugin doesn’t limit the item visibility strictly to that role, but considering it as the minimum base role in the site. An Administrator is able to view all items even though they are restricted to the subscribers. Because he or she has powers of all other user roles. In the same way, other users who are above the subscriber role too can view the same item.

Make sure to read the following related resources:


Share this