get_nav_menu_locations

The timeline below displays how wordpress function get_nav_menu_locations has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 5.9

/**
 * Retrieves all registered navigation menu locations and the menus assigned to them.
 *
 * @since 3.0.0
 *
 * @return int[] Associative array of registered navigation menu IDs keyed by their
 *               location name. If none are registered, an empty array.
 */
function get_nav_menu_locations()
{
    $locations = get_theme_mod('nav_menu_locations');
    return is_array($locations) ? $locations : array();
}

WordPress Version: 5.8

/**
 * Retrieves all registered navigation menu locations and the menus assigned to them.
 *
 * @since 3.0.0
 *
 * @return int[] Associative array of egistered navigation menu IDs keyed by their
 *               location name. If none are registered, an empty array.
 */
function get_nav_menu_locations()
{
    $locations = get_theme_mod('nav_menu_locations');
    return is_array($locations) ? $locations : array();
}

WordPress Version: 4.6

/**
 * Retrieves all registered navigation menu locations and the menus assigned to them.
 *
 * @since 3.0.0
 *
 * @return array Registered navigation menu locations and the menus assigned them.
 *               If none are registered, an empty array.
 */
function get_nav_menu_locations()
{
    $locations = get_theme_mod('nav_menu_locations');
    return is_array($locations) ? $locations : array();
}

WordPress Version: 3.7

/**
 * Returns an array with the registered navigation menu locations and the menu assigned to it
 *
 * @since 3.0.0
 * @return array
 */
function get_nav_menu_locations()
{
    $locations = get_theme_mod('nav_menu_locations');
    return is_array($locations) ? $locations : array();
}