wp_get_nav_menus() WordPress Function

The wp_get_nav_menus() function is used to retrieve a list of all available navigation menus. This function will return an array of all registered menus, with each menu being an object containing the following properties: - name - slug - description - count - items The wp_get_nav_menus() function is a useful way to get an overview of all the menus that are available to be used in your Wordpress site.

wp_get_nav_menus( array $args = array() ) #

Returns all navigation menu objects.


Parameters

$args

(array)(Optional) Array of arguments passed on to get_terms().

Default value: array()


Top ↑

Return

(WP_Term[]) An array of menu objects.


Top ↑

Source

File: wp-includes/nav-menu.php

function wp_get_nav_menus( $args = array() ) {
	$defaults = array(
		'taxonomy'   => 'nav_menu',
		'hide_empty' => false,
		'orderby'    => 'name',
	);
	$args     = wp_parse_args( $args, $defaults );

	/**
	 * Filters the navigation menu objects being returned.
	 *
	 * @since 3.0.0
	 *
	 * @see get_terms()
	 *
	 * @param WP_Term[] $menus An array of menu objects.
	 * @param array     $args  An array of arguments used to retrieve menu objects.
	 */
	return apply_filters( 'wp_get_nav_menus', get_terms( $args ), $args );
}


Top ↑

Changelog

Changelog
VersionDescription
4.1.0Default value of the 'orderby' argument was changed from 'none' to 'name'.
3.0.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.