Wordpress - Calling the Menu Title within wp_nav_menu array function
You can not get the menu title using wp_nav_menu()
, you need to get the menu object as follow:
//Change with the ID of your menu
$menu_ID = 5;
$nav_menu = wp_get_nav_menu_object( $menu_ID );
// then echo the name of the menu
echo $nav_menu->name;
With the above code, you can insert the menu name in wp_nav_menu()
using items_wrap
parameter. For example:
$menu_ID = 5;
$nav_menu = wp_get_nav_menu_object( $menu_ID );
wp_nav_menu( array(
'theme_location' => 'resources',
'container' => 'div',
'container_class' => 'rmm-footer',
'items_wrap' => '<ul><li id="item-id">'.$nav_menu->name.'</li>%3$s</ul>'
)
);