Plugin Directory

Codepress Menu

Allows you to display a sub-menu, it's depth from there on and gives you good control over the menu-item classes.

Uses the native wp_nav_menu() but adds some flexibility.

No configuration required, just adds runtime parameters that can be used to tweak your menu.

This will get the first sub-menu from the active branch and 2 levels beyond (menu + sub-menu + sub-menu):

wp_nav_menu( array(
    'level' => 2,
    'depth' => 3
));

Show the whole current branch only:

wp_nav_menu( array(
    'level' => 1
));

Aimed on simple use on various use cases:

// display first level in the header
wp_nav_menu( array(
    'depth' => 1
));

// display first sub-menu from the current branch somewhere else
wp_nav_menu( array(
    'depth' => 2,
    'level' => 2
));

Another feature is it's controll over the css classes that are assigned. You might be faced with a html template of which you cannot or do not want to change the css.

Use the filter 'codepress_menu_filter_classes' to define your own class filter.

There are also a few pre-configured variants:

  • sanitize Keep only a few WordPress classes (li.current-menu-item, li.current-menu-parent, li.current-menu-ancestor) and add li.first and li.last.
  • simple Use even more simple classes (li.current, li.current-parent, li.current-ancestor) and add li.first and li.last.
  • minimal Same as simple, but without list.first and li.last because you target modern browsers only or use something like selectivizr
  • false Do nothing (default)
wp_nav_menu( array(
    'classes' => 'sanitize'
));

Requires: 3.1 or higher
Compatible up to: 3.4.2
Last Updated: 2013-3-15
Downloads: 1,728

Ratings

5 stars
5 out of 5 stars

Support

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

Got something to say? Need help?

Compatibility

+
=
Not enough data

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

100,1,1 100,1,1 100,3,3
100,1,1