PHPackages                             log1x/navi - 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. log1x/navi

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

log1x/navi
==========

A developer-friendly alternative to the WordPress NavWalker.

v3.1.2(2mo ago)367633.2k—4.2%305MITPHPPHP ^8.0

Since Jun 20Pushed 2mo ago13 watchersCompare

[ Source](https://github.com/Log1x/navi)[ Packagist](https://packagist.org/packages/log1x/navi)[ GitHub Sponsors](https://github.com/Log1x)[ RSS](/packages/log1x-navi/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (21)Used By (5)

Navi
====

[](#navi)

[![Latest Stable Version](https://camo.githubusercontent.com/121c44fa257f87a83c723d6ecdc2779f4357ea8561817c2f497e663309dc5b5f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c6f6731782f6e6176692e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/121c44fa257f87a83c723d6ecdc2779f4357ea8561817c2f497e663309dc5b5f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c6f6731782f6e6176692e7376673f7374796c653d666c61742d737175617265)[![Total Downloads](https://camo.githubusercontent.com/d59c751e1b906d45ae0cec383c20dc779db3b03b8c8210c21ef5518134216862/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c6f6731782f6e6176692e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/d59c751e1b906d45ae0cec383c20dc779db3b03b8c8210c21ef5518134216862/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c6f6731782f6e6176692e7376673f7374796c653d666c61742d737175617265)[![Build Status](https://camo.githubusercontent.com/2bc7625e937e3516639183a29e7670dfd41e7496d83f3a04d490cceb513022dc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6c6f6731782f6e6176692f6d61696e2e796d6c3f6272616e63683d6d6173746572267374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/2bc7625e937e3516639183a29e7670dfd41e7496d83f3a04d490cceb513022dc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6c6f6731782f6e6176692f6d61696e2e796d6c3f6272616e63683d6d6173746572267374796c653d666c61742d737175617265)

Hate the WordPress NavWalker? **Me too**.

Navi is a developer-friendly alternative to the NavWalker. Easily build your WordPress menus using an iterable object inside of a template/view.

Requirements
------------

[](#requirements)

- [PHP](https://secure.php.net/manual/en/install.php) &gt;= 8.0

Installation
------------

[](#installation)

### Bedrock (or Sage)

[](#bedrock-or-sage)

Install via Composer:

```
$ composer require log1x/navi
```

### Manual

[](#manual)

Download the [latest release](https://github.com/Log1x/navi/releases/latest) `.zip` and install into `wp-content/plugins`.

Usage
-----

[](#usage)

Building your menu can be done by passing your menu location to `Navi::make()->build()`:

```
use Log1x\Navi\Navi;

$menu = Navi::make()->build('primary_navigation');
```

By default, `build()` uses `primary_navigation` if no menu location is specified.

Retrieving an array of menu items can be done using `all()`:

```
if ($menu->isNotEmpty()) {
    return $menu->all();
}
```

Note

Check out the [**examples**](examples) folder to see how to use Navi in your project.

### Menu Item Classes

[](#menu-item-classes)

By default, Navi removes the default WordPress classes from menu items such as `menu-item` and `current-menu-item` giving you full control over your menu markup while still passing through custom classes.

If you would like these classes to be included on your menu items, you may call `withDefaultClasses()` before building your menu:

```
$menu = Navi::make()->withDefaultClasses()->build();
```

In some situations, plugins may add their own classes to menu items. If you would like to prevent these classes from being added, you may pass an array of partial strings to `withoutClasses()` match against when building.

```
$menu = Navi::make()->withoutClasses(['shop-'])->build();
```

### Accessing Menu Object

[](#accessing-menu-object)

When building the navigation menu, Navi retains the menu object and makes it available using the `get()` method.

By default, `get()` returns the raw [`wp_get_nav_menu_object()`](https://codex.wordpress.org/Function_Reference/wp_get_nav_menu_object) allowing you to access it directly.

```
$menu->get()->name;
```

Optionally, you may pass a `key` and `default` to call a specific object key with a fallback when the value is blank:

```
$menu->get('name', 'My menu title');
```

### Accessing Page Objects

[](#accessing-page-objects)

If your menu item is linked to a page object (e.g. not a custom link) – you can retrieve the ID of the page using the `objectId` attribute.

Below is an example of getting the post type of the current menu item:

```
$type = get_post_type($item->objectId)
```

### Accessing Custom Fields

[](#accessing-custom-fields)

In a scenario where you need to access a custom field attached directly to your menu item – you can retrieve the ID of the menu item using the `id` attribute.

Below we'll get a label override field attached to our menu [using ACF](https://www.advancedcustomfields.com/resources/adding-fields-menus/) – falling back to the default menu label if the field is empty.

```
$label = get_field('custom_menu_label', $item->id) ?: $item->label;
```

### Acorn Usage

[](#acorn-usage)

If you are using Navi alongside [Acorn](https://roots.io/acorn/) (e.g. Sage), you may generate a usable view component using Acorn's CLI:

```
$ wp acorn navi:make Menu
```

Once generated, you may use the [view component](https://laravel.com/docs/11.x/blade#components) in an existing view like so:

```

```

To list all registered locations and their assigned menus, you can use the list command:

```
$ wp acorn navi:list
```

Example Output
--------------

[](#example-output)

When calling `build()`, Navi will retrieve the WordPress navigation menu assigned to the passed location and build out an array containing the menu items.

An example of the menu output can be seen below:

```
array [
  5 => {
    +"active": true
    +"activeAncestor": false
    +"activeParent": false
    +"classes": "example"
    +"dbId": 5
    +"description": false
    +"id": 5
    +"label": "Home"
    +"object": "page"
    +"objectId": "99"
    +"parent": false
    +"slug": "home"
    +"target": "_blank"
    +"title": false
    +"type": "post_type"
    +"url": "https://sage.test/"
    +"xfn": false
    +"order": 1
    +"parentObjectId": false
    +"children": false
  }
  6 => {
    +"active": false
    +"activeAncestor": false
    +"activeParent": false
    +"classes": false
    +"dbId": 6
    +"description": false
    +"id": 6
    +"label": "Sample Page"
    +"object": "page"
    +"objectId": "100"
    +"parent": false
    +"slug": "sample-page"
    +"target": false
    +"title": false
    +"type": "post_type"
    +"url": "https://sage.test/sample-page/"
    +"xfn": false
    +"order": 2
    +"parentObjectId": false
    +"children": array [
      7 => {
        +"active": false
        +"activeAncestor": false
        +"activeParent": false
        +"classes": false
        +"dbId": 7
        +"description": false
        +"id": 7
        +"label": "Example"
        +"object": "custom"
        +"objectId": "101"
        +"parent": 6
        +"slug": "example"
        +"target": false
        +"title": false
        +"type": "custom"
        +"url": "#"
        +"xfn": false
        +"order": 3
        +"parentObjectId": 100
        +"children": array [
          ...
        ]
      }
    ]
  }
]
```

Bug Reports
-----------

[](#bug-reports)

If you discover a bug in Navi, please [open an issue](https://github.com/Log1x/navi/issues).

Contributing
------------

[](#contributing)

Contributing whether it be through PRs, reporting an issue, or suggesting an idea is encouraged and appreciated.

License
-------

[](#license)

Navi is provided under the [MIT License](LICENSE.md).

###  Health Score

65

—

FairBetter than 99% of packages

Maintenance83

Actively maintained with recent releases

Popularity57

Moderate usage in the ecosystem

Community32

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 79.8% 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 ~128 days

Recently: every ~174 days

Total

20

Last Release

87d ago

Major Versions

v1.0.6 → v2.0.02021-02-14

v2.0.5 → v3.0.02024-03-18

PHP version history (4 changes)v1.0.0PHP &gt;=7.1

v1.0.2PHP &gt;=7.1.3

v2.0.0PHP ^7.0|^8.0

v3.0.0PHP ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5745907?v=4)[Brandon](/maintainers/Log1x)[@Log1x](https://github.com/Log1x)

---

Top Contributors

[![Log1x](https://avatars.githubusercontent.com/u/5745907?v=4)](https://github.com/Log1x "Log1x (71 commits)")[![mike-sheppard](https://avatars.githubusercontent.com/u/1690006?v=4)](https://github.com/mike-sheppard "mike-sheppard (3 commits)")[![codepuncher](https://avatars.githubusercontent.com/u/8135396?v=4)](https://github.com/codepuncher "codepuncher (2 commits)")[![szepeviktor](https://avatars.githubusercontent.com/u/952007?v=4)](https://github.com/szepeviktor "szepeviktor (2 commits)")[![timalbert](https://avatars.githubusercontent.com/u/282539?v=4)](https://github.com/timalbert "timalbert (2 commits)")[![zacksmash](https://avatars.githubusercontent.com/u/6118407?v=4)](https://github.com/zacksmash "zacksmash (2 commits)")[![retlehs](https://avatars.githubusercontent.com/u/115911?v=4)](https://github.com/retlehs "retlehs (1 commits)")[![slackday](https://avatars.githubusercontent.com/u/154369?v=4)](https://github.com/slackday "slackday (1 commits)")[![slobich](https://avatars.githubusercontent.com/u/2310439?v=4)](https://github.com/slobich "slobich (1 commits)")[![theMosaad](https://avatars.githubusercontent.com/u/48773133?v=4)](https://github.com/theMosaad "theMosaad (1 commits)")[![conatus](https://avatars.githubusercontent.com/u/317734?v=4)](https://github.com/conatus "conatus (1 commits)")[![QWp6t](https://avatars.githubusercontent.com/u/2104321?v=4)](https://github.com/QWp6t "QWp6t (1 commits)")[![Reinpal](https://avatars.githubusercontent.com/u/3115818?v=4)](https://github.com/Reinpal "Reinpal (1 commits)")

---

Tags

navigation-menunavwalkersagewordpresswordpresswordpress pluginnavwalker

###  Code Quality

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/log1x-navi/health.svg)

```
[![Health](https://phpackages.com/badges/log1x-navi/health.svg)](https://phpackages.com/packages/log1x-navi)
```

###  Alternatives

[rilwis/meta-box

The most powerful &amp; comprehensive plugin to create, manage, show and connect dynamic data with forms and custom fields effortlessly on WordPress.

1.2k1.8k1](/packages/rilwis-meta-box)[hellonico/acf-country

A country field for ACF.

12193.2k](/packages/hellonico-acf-country)

PHPackages © 2026

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