how to access the name of menu in worpress

Solutions on MaxInterview for how to access the name of menu in worpress by the best coders in the world

showing results for - "how to access the name of menu in worpress"
Luciano
19 Nov 2017
1wp_get_nav_menu_name($location)
2
Irene
13 Aug 2018
1$menu_location = 'header';
2
3$menu_locations = get_nav_menu_locations();
4
5$menu_object = (isset($menu_locations[$menu_location]) ? wp_get_nav_menu_object($menu_locations[$menu_location]) : null);
6
7$menu_name = (isset($menu_object->name) ? $menu_object->name : '');
8
9echo esc_html($menu_name);
10
Clara
30 Sep 2020
1$menu = wp_get_nav_menu_object("my mainmenu" );
2
Langdon
09 Nov 2018
1<?php $menu_name = 'sidebar-menu'; //menu slug or menu location
2$locations = get_nav_menu_locations();
3$menu = wp_get_nav_menu_object( $locations[ $menu_name ] );
4$menuitems = wp_get_nav_menu_items( $menu->term_id, array( 'order' => 'DESC' ) );
5 
6echo "<pre>";
7print_r($menuitems);
8echo "</pre>";
9?>
10
Mila
13 Sep 2016
1$menu = wp_get_nav_menu_object("my-mainmenu" );
2
Max
19 May 2016
1 Object (
2   term_id => 4
3   name => My Menu Name
4   slug => my-menu-name
5   term_group => 0
6   term_taxonomy_id => 4
7   taxonomy => nav_menu
8   description => 
9   parent => 0
10   count => 6
11 )
12
Elias
26 Aug 2020
1echo $menu->name;
2