
This is a simple plugin that was born out of working on several projects with sectional navigations. For example, consider the following common navigation tree structure:
Then, whenever on the “About Us” page or any of its sub-items, it would output that peice of the navigation:
This is particularly useful for websites that have a top horizontal navigation which shows top-level items and want to show a vertical subnavigation in the sidebar.
This plugin works by parsing the output of the wp_nav_menu function as XML and analyzing the CSS class hooks (current-menu-ancestor, current-menu-item, and current-menu-parent). Because it uses PHP’s SimpleXML library it therefore requires PHP 5+. It uses the theme’s registered menu locations.
This plugin also exposes the section_subnav() function for theme developers to use as a template tag to manually place a subnav inside the theme. Here is the usage:
<?php
section_subnav( array( // defaults
'before_widget' => '<nav id="section-subnav" class="widget widget_section-subnav">',
'after_widget' => "</nav>",
'before_title' => '<h3 class="section-subnav-title widget-title">',
'after_title' => '</h3>',
'echo' => true
));
?>
It returns false when there is no subnavigation.
This function also provides the section_subnav_args filter hook for writing less code and easier integration with other plugins and child themes.
Download & install the zip archive
The plugin package installer can be downloaded from the WP2E project tab called “code”.
1 – Select the version to download if this option is available otherwise the “latest” version of the main plugin will be used.
2 – After downloading the zip archive install the plugin package installer in you local environment and activate the script from the plugin list.
3 – Under the section “Plugins” of the admin dashboard you should see a new “Dependencies & Licenses” link. Follow the instructions from this panel to finalize the installation of the missing dependencies.
Tips: Use the WP2E panel to add/suggest new dependencies to the local installation. Press F5 in the list of dependencies if the changes are not displayed right away.