WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to output the title of wp_nav_menu somehow? The closest I could find was http://codex.wordpress.org/Function_Reference/wp_nav_menu#Adding_a_Word_at_the_Beginning_of_the_Menu. For the sake of the client and the inclusion of Polylang, I figured it would be nice to enable the user to edit these titles directly under the menu settings in the dashboard.

share|improve this question
up vote 2 down vote accepted

This outputs the title of a menu using wp_get_nav_menu_object (and prepends to the Content).

function pg_show_nav_menu_title ( $content ) {

    // ID of the menu you want
    $nav_menu_id = 14;

    //Get menu into an object
    $nav_menu_object = wp_get_nav_menu_object( $nav_menu_id );

    //Get the name (title)
    $nav_menu_title = $nav_menu_object->name;

    //String to return as Content
    $content = 'Nav menu title: ' . $nav_menu_title . '<br>' . $content;

    return $content;

add_filter( 'the_content' , 'pg_show_nav_menu_title' );

Note: You can get the id of any menu in Dashboard > Appearance > Menus. Right-click on the Select menu and show source. The numbers in the options are the IDs. In the example above, I grabbed '14' from:

<select name="menu" id="menu">
    <option value="14">Primary</option>
    <option value="237">Top (Secondary Navigation Menu)</option>
share|improve this answer
Thank you Pat, that worked great! – Staffan Estberg Jun 23 '14 at 6:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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