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

I'd like to get a menu object from its theme location argument.

My goal is to output separately the menu name and its items name, url and description.

Example of what I'm looking for :

$menu = get_menu('nav-menu'); //get menu from its theme location
echo $menu->name; //displays the menu name
foreach($menu->items as $item){
    echo '<a href="'.$item->link'">'.$item->name.'</a>'; //displays a link to the item destination
    echo $item->description; //displays the item description
share|improve this question
up vote 6 down vote accepted

This method looks like what you're looking for, using get_nav_menu_locations() and get_term():

$theme_locations = get_nav_menu_locations();

$menu_obj = get_term( $theme_locations[$theme_location], 'nav_menu' );

$menu_name = $menu_obj->name;

(See the link for the whole thing wrapped up in a custom function; the above code just highlights the relevant WP functions for getting what you're after.)

share|improve this answer
Thanks, that did the trick ! – Morhaus Sep 25 '11 at 19:26

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.