I am looking for a way to include a user managable title in a menu. Ideally, it will take the place of the first <li> object in the output.

Any ideas?

Edit Clarification

I am looking for a way to add a header to a menu list, defined by the given name of the menu in the admin panel.

So, the code should look a little like this:

  <li class="title"> Menu Name</li>
  <li><a href=#>Link</a></li>
  <li><a href=#>Link</a></li>
  <li><a href=#>Link</a></li>
  <li><a href=#>Link</a></li>

Edit Further Development

I have a code block for extracting the name of a menu, based on it's location in a theme, but I can't quite get the HTML layout I want (i.e. add the title to the first <li>).

function mf_get_menu_name($location){
    if(!has_nav_menu($location)) return false;
    $menus = get_nav_menu_locations();
    $menu_title = wp_get_nav_menu_object($menus[$location])->name;
    return $menu_title;
  • care to explain a bit more? – Bainternet Jul 19 '11 at 11:01
  • Added clarification and details of where I am with the problem. – Mild Fuzz Jul 19 '11 at 15:39

Are you looking to put a title on the nav links? That is built into the Menu feature in Wordpress.

Wordpress Title Menu

But this applies to the tag and not the <li> as you specified. You can, however, apply a class to the <li> by clicking the "Screen Options" link while in the Menu Admin page. Then, find the "CSS Class" checkbox under "Show advanced menu properties".

Finally, you could give your links the desired title and then apply the following jQuery to apply the title to the <li> and remove it from the <a>.

$(function() {

    $('ul li').each(function() {

        var linkTitle = $(this).find('a').attr('title'); //get the link title
        $(this).attr('title', linkTitle); //apply the title to the li



JSFiddle example: http://jsfiddle.net/tmort/E5VzC/3/

  • Sorry, not really what I meant, I have explained further in the question. – Mild Fuzz Jul 19 '11 at 19:23

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.