Retrieves all registered navigation menu locations and the menus assigned to them.
Source
function get_nav_menu_locations() {
$locations = get_theme_mod( 'nav_menu_locations' );
return ( is_array( $locations ) ) ? $locations : array();
}
Changelog
Version | Description |
---|---|
3.0.0 | Introduced. |
Allows the editor role to modify menus
Just to Update on the ‘return’ statement, it returns ‘integer’ for individual ‘menu-location’ if no menu is assigned. To be precise, it returns an Array like so:
Returns an array like so
Array
(
[main-menu] => 757
[mobile-menu] => 1506
[footer-menu] => 0
)
main-menu and mobile-menu are assigned so they return Menu ID whereas footer-menu is unassigned and thus returns ‘0’.