get_nav_menu_locations

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

Description

(array) get_nav_menu_locations(); 

Returns (array)

Registered navigation menu locations and the menus assigned them. If none are registered, an empty array.


Usage

  1. if ( !function_exists( 'get_nav_menu_locations' ) ) { 
  2. require_once ABSPATH . WPINC . '/nav-menu.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = get_nav_menu_locations(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/nav-menu.php  
  1. function get_nav_menu_locations() { 
  2. $locations = get_theme_mod( 'nav_menu_locations' ); 
  3. return ( is_array( $locations ) ) ? $locations : array();