WordPress.org

Plugin Directory

If Menu

Show/hide menu items with conditional statements

If Menu is broken

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 the functionality for menu items.

How can I add a conditinal statement for menu items?

New conditional statements can be added by any other plugins or themes.

Example of adding a new conditional statement for disaplying/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(
    'name'    =>  'If single custom-post-type', // name of the condition
    'condition' =>  function($item) {          // callback - must return TRUE or FALSE
      return is_singular( 'my-custom-post-type' );
    }
  );

  return $conditions;
}

Where do I find conditional functions?

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

Who made that really cool icon

Got the icons from here https://dribbble.com/shots/1045549-Light-Switches-PSD, so giving the credit to Louie Mantia

Requires: 3.7 or higher
Compatible up to: 4.3.3
Last Updated: 2 months ago
Active Installs: 10,000+

Ratings

4.4 out of 5 stars

Support

1 of 8 support threads in the last two months have been marked resolved.

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.

0,1,0
100,1,1
100,1,1
100,1,1
0,1,0
100,1,1
100,1,1
100,2,2
50,2,1
100,1,1
33,3,1 50,2,1
100,1,1