How to Add Conditional Menus to WordPress

Using the built in WordPress navigation menus is the most convenient way to handle custom menus since the 3.0 release. Since then, developers have written all kinds of plugins to add additional functionality to this theme feature.

If Menu is the latest plugin written to extend WordPress navigation menus. It allows you to show or hide individual menu items based on conditional statements, such as whether or not a user is logged in, various user roles, and the type of content being viewed, (ie, front page, single, page).

When the plugin is enabled, each menu item will get a new checkbox option to “Enable Conditional Logic”.

The plugin currently includes several conditional statements and the developer will be adding more in future releases. You can also add your own by following the instructions on the FAQ page.

If you need to apply conditional logic to individual menu items within the native WordPress navigation menus, this plugin offers you the easiest way to do that. Download the If Menu plugin for free from the WordPress plugin repository.


Comments (7)

  1. Not bad. The plugin offers a fairly basic approach to conditional menu items placement. The average user may find use for this. For a bit more of an advanced approach alternatives could be sought out.

  2. It took a month for the plugin author to respond, but here it is:

    Plugin Author
    Posted 2 hours ago #


    Unfortunately, the API support for menus is not so good, and just one Walker can be assigned for editing menu items.

    When another plugin/theme is hooked to the ‘edit-menu-item’, this plugin disabled

  3. I added a “User not logged in” condition with the following code:

    * Adds a new condition for users who are not logged in.
    add_filter( ‘if_menu_conditions’, function( $conditions ){
    $conditions[] = array(
    ‘name’ => __( ‘User is not logged in’, ‘if-menu’ ),
    ‘condition’ => ‘if_menu_is_user_not_logged_in’
    return $conditions;

    * Checks if the current visitor is not logged in.
    * @return bool True if the user is not logged in, false if logged in.
    function woynet_plugin_if_menu_is_user_not_logged_in() {
    return !is_user_logged_in();