Found Image WordPress wp nav menu Filter | Plugin Review Network Skip to Content

Plugin Review Network

Plugin Review Network

an eye on the best wordpress plugins
Show Sidebar Hide Sidebar
[+] Sidebar [-] Sidebar
Plugin:
Rated:
100%
5 Stars (2 votes)

Home

WP.Org

ReadMe

Support
  • Author:
    Travis Hoglund
Version: 1.1
Requires: WP 3.0.0
Last Updated:4156 days ago
Downloads:8191
Installations: 900+
Usage Retention:10.99%
Tags:
    filter, menu, nav, nav filter, sub-menu, submenu, submenu filter, wordpress filter submenu, wordpress menus, wordpress nav filter, wordpress submenu, wp nav menu, wp_nav_menu
Download Plugin Package

WordPress wp nav menu Filter

Released on March 8, 2012.
Download Plugin Package

Version: 1.1

Adds the ability to pass an argument (pageID or page name) to show a filtered submenu with wp_nav_menu().

  • Description
  • FAQ
  • Changelog
  • Installation


If you have built custom WordPress themes, you have probably ran into needing to display navigation on subpages. Rather than try to manage several navigation menus, or try to output menus with wp_list_pages(), why not manage everything from a single menu, and just pass different parameters to show what you want? Makes sense to me...

To use it, simply add a 'submenu' parameter to the arguments of wp_nav_menu, like so:

wp_nav_menu(array(
  'menu' => 'header',
  'submenu' => 'Solutions' //Using parameter of Page Name
));

----  OR  ----

wp_nav_menu(array(
  'menu' => 'header',
  'submenu' => '46' //Using parameter of Page ID (!important - Passing ID in STRING FORMAT)
));

What will happen if I pass an invalid page ID?

It defaults to the main menu, the same as if the plugin wasn't activated/installed.

How do I select a menu more than one level deep?

You can go multiple levels deep by putting slashes in:

wp_nav_menu(array(
  'menu' => 'header',
  'submenu' => 'Solutions/Company Solutions'
));

Or you can also use an Array:

wp_nav_menu(array(
  'menu' =>
  'submenu' => array('Solutions', 'Company Solutions')
));

Can I use a page's slug instead of the page title?

Currently, I see no reason to use a page slug. This functionality can be added at a later date if I see it to be necessary.

Does the title need to match exactly?

This plugin should compare the page title with what you entered and be slightly forgiving (Capital letters, etc), but you should strive to enter it exactly.

Example for inside template files:

wp_reset_query();  //Good practice to clear any of your custom loops before this code

wp_nav_menu(array(
  'menu' => 'header',
  'submenu' => ''.$post->ID.'' //This will always provide an exact match to the current loop page
));

1.0

  • Version 1.0 Released.

1.1

  • Version 1.1 Released.
  • Checked compatibility with latest version of WP - no changes needed.


Install this plugin in the normal way:

  1. Place it in your /wp-content/plugins/ directory
  2. Activate the plugin through the 'Plugins' menu in WordPress
  3. Use the wp_nav_menu function with a submenu parameter in your templates

    wp_nav_menu(array( 'menu' => 'header', 'submenu' => 'Solutions' ));

    wp_nav_menu(array( 'menu' => 'header', 'submenu' => '46' )); //Important - You MUST pass the ID as a STRING!


 

Click here to cancel reply.

Click here to cancel reply.


*

*


Please copy the string oofpCB to the field below:

Home | Sitemap | Contact
Network Skin Theme for BioShip by WordQuest
Password Reset
Please enter your e-mail address. You will receive a new password via e-mail.