wp_get_nav_menus( array $args = array() )

Returns all navigation menu objects.


Parameters Parameters

$args

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

Default value: array()


Top ↑

Return Return

(WP_Term[]) An array of menu objects.


Top ↑

Source 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

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

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.