PHPackages                             mwdelaney/sage-wp-nav-submenu - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. mwdelaney/sage-wp-nav-submenu

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

mwdelaney/sage-wp-nav-submenu
=============================

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

1.0.4(6y ago)75.5k1[1 issues](https://github.com/MWDelaney/sage-wp-nav-submenu/issues)[1 PRs](https://github.com/MWDelaney/sage-wp-nav-submenu/pulls)MITPHPPHP &gt;=5.3.2

Since Feb 26Pushed 6y agoCompare

[ Source](https://github.com/MWDelaney/sage-wp-nav-submenu)[ Packagist](https://packagist.org/packages/mwdelaney/sage-wp-nav-submenu)[ Docs](https://github.com/MWDelaney/sage-wp-nav-submenu)[ RSS](/packages/mwdelaney-sage-wp-nav-submenu/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)DependenciesVersions (6)Used By (0)

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

[](#sage-9-friendly-method-for-getting-wp_nav_menu-submenu-items-based-on-parent-or-sibling)

This package is based entirely on [this code](https://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-based-on-parent-or-sibling/) from [levymetal](https://github.com/levymetal).

The instructions below are also taken from [levymetal](https://github.com/levymetal)'s excellent documentation.

To install, run the following in your Sage9-based theme directory:

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

```

Include the submenu arguemnts in your wp\_nav\_menu function:

```
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.

```
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.

```
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.

```
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.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 90% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~182 days

Total

5

Last Release

2269d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8eeadbfceef9e730e3df7fe1e01b12742f28e8f7d8bf52ed87d01d41b8918adb?d=identicon)[MWDelaney](/maintainers/MWDelaney)

---

Top Contributors

[![MWDelaney](https://avatars.githubusercontent.com/u/2457670?v=4)](https://github.com/MWDelaney "MWDelaney (9 commits)")[![MikaCaldera](https://avatars.githubusercontent.com/u/5650312?v=4)](https://github.com/MikaCaldera "MikaCaldera (1 commits)")

---

Tags

wordpresssubmenunav-menu

### Embed Badge

![Health badge](/badges/mwdelaney-sage-wp-nav-submenu/health.svg)

```
[![Health](https://phpackages.com/badges/mwdelaney-sage-wp-nav-submenu/health.svg)](https://phpackages.com/packages/mwdelaney-sage-wp-nav-submenu)
```

###  Alternatives

[tgmpa/tgm-plugin-activation

TGM Plugin Activation is a PHP library that allows you to easily require or recommend plugins for your WordPress themes (and plugins).

1.8k222.5k13](/packages/tgmpa-tgm-plugin-activation)[aristath/kirki

Extending the WordPress customizer

1.3k73.0k4](/packages/aristath-kirki)[afragen/git-updater

A plugin to automatically update GitHub, Bitbucket, GitLab, or Gitea hosted plugins, themes, and language packs.

3.3k1.6k](/packages/afragen-git-updater)[justintadlock/hybrid-carbon

God-like post featured image script.

202.5k](/packages/justintadlock-hybrid-carbon)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
