Calling get_nav_menu_locations() will show you an array of all the nav location slugs and their associated menu ID you have registered/ and or used in the past. The get_nav_menu_locations() function checks a theme mod so to fully unregister/remove menu location we need an extra step missing from unregister_nav_menu() by removing the location slug from the get_theme_mod(‘nav_menu_locations’) array and then resetting the theme mod without the $location we want to remove.
/**
* Delete a previously registered location
*
* @param $location The slug used to register the menu in the first place
*/
if (!function_exists('delete_nav_menu_location')) {
function delete_nav_menu_location($location)
{
$locations = get_theme_mod('nav_menu_locations');
if (is_array($locations) && array_key_exists($location, $locations)) {
unset($locations[$location]);
set_theme_mod('nav_menu_locations', $locations);
return true;
}
return false;
}
}
Delete a previously registered location
Calling get_nav_menu_locations() will show you an array of all the nav location slugs and their associated menu ID you have registered/ and or used in the past. The get_nav_menu_locations() function checks a theme mod so to fully unregister/remove menu location we need an extra step missing from unregister_nav_menu() by removing the location slug from the get_theme_mod(‘nav_menu_locations’) array and then resetting the theme mod without the $location we want to remove.
Basic Example