The three functions you'll need to use are these:
- get_registered_nav_menus()
- wp_get_nav_menus()
- get_nav_menu_locations()
get_registered_nav_menus: This will give you a list of locations. The array keys will be the location slugs, and the array values will the location names.
wp_get_nav_menus: This will give you a list of menus the (presumably) the user created. The array will be full of objects. These are really just taxonomies.
get_nav_menu_locations: This will give you the information key to what you're looking for. The keys of the returned array will be the location slug, and the values of the returned array will be the taxonomy IDs of menu.
How to get the menu that belongs to a given location:
$locations = get_registered_nav_menus();
$menus = wp_get_nav_menus();
$menu_locations = get_nav_menu_locations();
$location_id = 'riddell-shop';
if (isset($menu_locations[ $location_id ])) {
foreach ($menus as $menu) {
// If the ID of this menu is the ID associated with the location we're searching for
if ($menu->term_id == $menu_locations[ $location_id ]) {
// This is the correct menu
// Get the items for this menu
$menu_items = wp_get_nav_menu_items($menu);
// Now do something with them here.
//
//
break;
}
}
} else {
// The location that you're trying to search doesn't exist
}
I hope that helps.