Kriuchko
1/8/2019 - 12:57 PM

Menu get menu locations get items by location

Wordpress get menu locations

$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
}