Been struggling with this for a little while. I want to call a menu but include the title of the menu above the menu list. The basic code I have is as follows -

<?php wp_nav_menu( array(
'container'       => 'div',
'container_class' => 'rmm-footer',
'theme_location'  => 'resources'

This produces a list as follows -

Menu Item 1 Menu Item 2 Menu Item 3

But I want it to go as follows -

TITLE Menu Item 1 Menu Item 2 Menu Item 3

Anyone got any ideas?

Thanks in advance.


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>'
  • 1
    If it wroked and answered your question, please, mark the answer as accepted. – cybmeta Jan 7 '15 at 10:52

It is better to not rely on menu Id, my solution will resolve dynamically the attached menu for the current location.

1- First we need to define a function that look for menu in our functions.php :

function monoprog_get_menu_by_location($location) {
    if(empty($location)) return false;

    $locations = get_nav_menu_locations();
    if(!isset($locations[$location])) return false;

    return get_term( $locations[$location], 'nav_menu' );

2- Then let's display the title of the menu displayed in any location we want :

$menu_obj = monoprog_get_menu_by_location('menufooterleft');
echo "<h3>".esc_html($menu_obj->name)."</h3>";

just replace 'menufooterleft' with the location registered in your theme.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.