WordPress at a glance

wp_get_nav_menus() WP 1.0

Returns all navigation menu objects.

Works based on: get_terms()
Hooks from the function
Return

Array. Menu objects.

Usage

wp_get_nav_menus( $args );
$args(array)
Array of arguments passed on to get_terms().
Default: empty array

Changelog

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

Code of wp get nav menus: wp-includes/nav-menu.php WP 5.2.2

<?php
function wp_get_nav_menus( $args = array() ) {
	$defaults = array(
		'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 array $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( 'nav_menu', $args ), $args );
}

Related Functions

From tag: nav menu (nav_menu)

More from category: Menu

No comments
    Hello, !     Log In . Register