If Menu - Visibility control for menu items

⭐️4.6 (88)

Plugins | Site Design | Menus

If Menu - Visibility control for menu items

Control what menu items your site’s visitors see, based on visibility rules.

400k+ downloads
50k+ active installations
Tested up to WP 5.2.4

← If Menu - Visibility control for menu items

Frequently Asked Questions

If Menu is broken, no visibility rules are available

The code for modifying the menu items is limited and if other plugins/themes try to alter the menu items, this plugin will break.

This is an ongoing issue with WordPress which hopefully will be fixed in a future release.

Try to use just one plugin that changes functionality for menu items.

How can I add a custom visibility rule for menu items?

New rules can be added by any other plugin or theme.

Example of adding a new custom rule for displaying/hiding a menu item when current page is a custom-post-type.

// theme's functions.php or plugin file
add_filter('if_menu_conditions', 'my_new_menu_conditions');

function my_new_menu_conditions($conditions) {
  $conditions[] = array(
    'id'        =>  'single-my-custom-post-type',                       // unique ID for the rule
    'name'      =>  __('Single my-custom-post-type', 'i18n-domain'),    // name of the rule
    'condition' =>  function($item) {                                   // callback - must return Boolean
      return is_singular('my-custom-post-type');
    }
  );

  return $conditions;
}

Where can I find conditional functions?

WordPress provides a lot of functions which can be used to create custom rules for almost any combination that a theme/plugin developer can think of.

Support

  • Version: 0.15
  • Last updated: 08 Apr 2019
  • Tested up to WordPress 5.2.4
  • Requires PHP 5.4 or higher
  • FAQ
  • Support forum

Still need help?

Please visit the Support forum on WordPress.org