On this page
wp_get_nav_menu_name( string $location ): string
Returns the name of a navigation menu.
Parameters
$locationstring Required-
Menu location identifier.
Return
string Menu name.
Source
File: wp-includes/nav-menu.php. View all references
function wp_get_nav_menu_name( $location ) {
$menu_name = '';
$locations = get_nav_menu_locations();
if ( isset( $locations[ $location ] ) ) {
$menu = wp_get_nav_menu_object( $locations[ $location ] );
if ( $menu && $menu->name ) {
$menu_name = $menu->name;
}
}
/**
* Filters the navigation menu name being returned.
*
* @since 4.9.0
*
* @param string $menu_name Menu name.
* @param string $location Menu location identifier.
*/
return apply_filters( 'wp_get_nav_menu_name', $menu_name, $location );
}
Hooks
- apply_filters( 'wp_get_nav_menu_name',
string $menu_name ,string $location ) -
Filters the navigation menu name being returned.
Related
Uses
| Uses | Description |
|---|---|
| wp_get_nav_menu_object() wp-includes/nav-menu.php | Returns a navigation menu object. |
| get_nav_menu_locations() wp-includes/nav-menu.php | Retrieves all registered navigation menu locations and the menus assigned to them. |
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
Changelog
| Version | Description |
|---|---|
| 4.9.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_get_nav_menu_name