2017 © Pedro Peláez
 

library sage-wp-nav-submenu

Get submenu items from a WordPress menu based on parent or sibling

image

mwdelaney/sage-wp-nav-submenu

Get submenu items from a WordPress menu based on parent or sibling

  • Monday, February 26, 2018
  • by MWDelaney
  • Repository
  • 1 Watchers
  • 2 Stars
  • 46 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 2 % Grown

The README.md

Sage 9 friendly method for getting wp_nav_menu() submenu items based on parent or sibling

This package is based entirely on this code from levymetal., (*1)

The instructions below are also taken from levymetal's excellent documentation., (*2)

To install, run the following in your Sage9-based theme directory:, (*3)

composer require "mwdelaney/sage-wp-nav-submenu"

Include the submenu arguemnts in your wp_nav_menu function:, (*4)

wp_nav_menu( array(
  'menu'     => 'Menu Name',
  ...
  'sub_menu' => true
) );

By default, if you have many nested levels, this code will filter the menu by the absolute top level parent. If you want the menu to drill down dynamically by filtering the menu based on the direct parent, pass a "direct_parent" => true parameter to the wp_nav_menu call., (*5)

wp_nav_menu( array(
  'menu'          => 'Menu Name',
  ...
  'sub_menu'      => true,
  'direct_parent' => true
) );

If you want to include the parent/root element in the menu, you can pass in a "show_parent" => true parameter to display the root level item., (*6)

wp_nav_menu( array(
  'menu'        => 'Menu Name',
  ...
  'sub_menu'    => true,
  'show_parent' => true
) );

If you want to include the parent/root element in the menu even if it has no children, you can pass in a "show_parent_only" => true parameter to display the root level item., (*7)

wp_nav_menu( array(
  'menu'        => 'Menu Name',
  ...
  'sub_menu'    => true,
  'show_parent' => true,
  'show_parent_only' => true
) );

Of course, you can continue to use the standard wp_nav_menu parameters as well. For example, if you want to limit the number of nested children being displayed, you can use the depth parameter. Or of you don’t want the menu to be displayed, you can use the echo parameter., (*8)

The Versions

26/02 2018

dev-master

9999999-dev https://github.com/MWDelaney/sage-wp-nav-submenu

Get submenu items from a WordPress menu based on parent or sibling

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

wordpress submenu nav_menu

26/02 2018

1.0.2

1.0.2.0 https://github.com/MWDelaney/sage-wp-nav-submenu

Get submenu items from a WordPress menu based on parent or sibling

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

wordpress submenu nav_menu

26/02 2018

1.0.1

1.0.1.0 https://github.com/MWDelaney/sage-wp-nav-submenu

Get submenu items from a WordPress menu based on parent or sibling

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

wordpress submenu nav_menu

26/02 2018

1.0

1.0.0.0 https://github.com/MWDelaney/sage-wp-nav-submenu

Get submenu items from a WordPress menu based on parent or sibling

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

wordpress submenu nav_menu