get_nav_menu_locations() WordPress Function

If your theme uses register_nav_menus(), the get_nav_menu_locations() function will retrieve an array of the registered menu locations and their assigned menus. This is useful for determining which menu locations a particular theme has active.

get_nav_menu_locations() #

Retrieves all registered navigation menu locations and the menus assigned to them.


Return

(int[]) Associative array of registered navigation menu IDs keyed by their location name. If none are registered, an empty array.


Top ↑

Source

File: wp-includes/nav-menu.php

function get_nav_menu_locations() {
	$locations = get_theme_mod( 'nav_menu_locations' );
	return ( is_array( $locations ) ) ? $locations : array();
}


Top ↑

Changelog

Changelog
VersionDescription
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.