How To Show/Hide WordPress Menus With Conditional Statements?

If Menu is a free WordPress plugin that enables you to use WordPress menus (each individual menu item) with if conditional statements, somewhat like WordPress widgets visibility feature by Jetpack. The plugin enables visibility features to all WordPress menus you manage from dashboard’s appearance section. It allows you display or hide menus based on conditional statements such as show/hide this menu if the page is a single page, if user is logged in etc.

To start, first install and activate If Menu plugin then visit your area Dashboard -> Appearance -> Menus page and select a menu from ‘Select a menu to edit‘ drop box. [Read: How To Create & Manage WordPress Menus?]

Now suppose you want to add a ‘Login’ link in your navigation menu but you want to show it only to logged out users (as it is of no use for logged in users) then first add the custom login to your menu structure and tick ‘Enable Conditional Logic ‘ checkbox. As soon you tick this option it starts showing a show/hide dropdown box with if conditional logic options as shown in the given screenshot. Now all you have to do is select a show or hide option and then choose your visibility conditions.

How To Use Conditional Statements With WordPress Menus?

In the above example we have selected hide option with conditional statement ‘if user is logged in’ to make login button automatically disappear for all logged in users. Alternatively, in given example’s case we can also use ‘show’ option for all ‘logged out’ users.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.