Чтобы получить в теме Wordpress название меню, которое назначено в определенную локацию, воспользуемся этими двумя функциями:
function _get_theme_menu( $theme_location ) {
if( ! $theme_location ) return false;
$theme_locations = get_nav_menu_locations();
if( ! isset( $theme_locations[$theme_location] ) ) return false;
$menu_obj = get_term( $theme_locations[$theme_location], 'nav_menu' );
if( ! $menu_obj ) $menu_obj = false;
return $menu_obj;
}
if( ! $theme_location ) return false;
$theme_locations = get_nav_menu_locations();
if( ! isset( $theme_locations[$theme_location] ) ) return false;
$menu_obj = get_term( $theme_locations[$theme_location], 'nav_menu' );
if( ! $menu_obj ) $menu_obj = false;
return $menu_obj;
}
function _get_theme_menu_name( $theme_location ) {
if( ! $theme_location ) return false;
$menu_obj = _get_theme_menu( $theme_location );
if( ! $menu_obj ) return false;
if( ! isset( $menu_obj->name ) ) return false;
return $menu_obj->name;
}
Функция _get_theme_menu() возвращает объект меню, назначенного в локацию, а _get_theme_menu_name() - непосредственно название меню.