WordPress filter hook · part of WordPress core

wp_nav_menu_items

A WordPress core filter that 4 plugins also fire themselves, running on 9,110+ sites between them.

“Filters the HTML list content for navigation menus.”

How to use wp_nav_menu_items

It's a filter: your callback receives the value and 1 more argument, and must return the (changed) value. Add this to your theme's functions.php or a small custom plugin:

functions.php
add_filter( 'wp_nav_menu_items', function( $items, $args ) {
	// Change $items here.
	return $items;
}, 10, 2 );

Argument names come from EasyMega's source. Other plugins may pass different values: check the call in the plugin you're targeting below.

This hook is fired by WordPress core too. Official reference on developer.wordpress.org →

4 plugins that fire wp_nav_menu_items

Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.

  1. EasyMega icon EasyMega5,000+ installs apply_filters( 'wp_nav_menu_items', $items, $args ) inc/menu.php:186
  2. Groovy Menu Plugin (Free) icon Groovy Menu Plugin (Free)4,000+ installs apply_filters( 'wp_nav_menu_items', $items, $args ) includes/modules/core/inc/GroovyMenuUtils.php:2093
  3. Voce Cached Nav icon Voce Cached Nav100+ installs apply_filters( 'wp_nav_menu_items', $items, $args ) voce-cached-nav.php:291
  4. Line Style Menus icon Line Style Menus10+ installs apply_filters( 'wp_nav_menu_items', $items, $args ) line-style-menu.php:291

Need a customisation built on this hook?

Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.