Title: Get menu items
Last modified: August 22, 2016

---

# Get menu items

 *  [SergioDev](https://wordpress.org/support/users/zejio/)
 * (@zejio)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/get-menu-items/)
 * Hello!
 * I’m trying to get a menu items created from wordpress admin panel.
 * To do this I followed the instructions codex:
    [http://codex.wordpress.org/Function_Reference/wp_get_nav_menu_items](http://codex.wordpress.org/Function_Reference/wp_get_nav_menu_items)
 *     ```
       // Get the nav menu based on $menu_name (same as 'theme_location' or 'menu' arg to wp_nav_menu)
           // This code based on wp_nav_menu's code to get Menu ID from menu slug
   
           $menu_name = 'custom_menu_slug';
   
           if ( ( $locations = get_nav_menu_locations() ) && isset( $locations[ $menu_name ] ) ) {
       	$menu = wp_get_nav_menu_object( $locations[ $menu_name ] );
   
       	$menu_items = wp_get_nav_menu_items($menu->term_id);
   
       	$menu_list = '<ul id="menu-' . $menu_name . '">';
   
       	foreach ( (array) $menu_items as $key => $menu_item ) {
       	    $title = $menu_item->title;
       	    $url = $menu_item->url;
       	    $menu_list .= '<li><a href="' . $url . '">' . $title . '</a></li>';
       	}
       	$menu_list .= '</ul>';
           } else {
       	$menu_list = '<ul><li>Menu "' . $menu_name . '" not defined.</li></ul>';
           }
           // $menu_list now ready to output
       echo $menu_list;
       ```
   
 * But I get always the error: Menu “cs-1-language” not defined.
 * I tried with the name and the slug and different menus but I always find that
   error.
 * Does anyone know what I’m doing wrong or if there is another way to list the 
   items of a menu?
 * Thanks!

Viewing 1 replies (of 1 total)

 *  [d2.roth](https://wordpress.org/support/users/d2roth/)
 * (@d2roth)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/get-menu-items/#post-5823311)
 * Hey SergioDev,
    I am sure you have solved this problem but This is for anyone
   coming to this page with the same problem.
 * Basically in the WordPress backend you need to set the menu to the location. 
   For example SergioDev had the error saying ‘Menu “cs-1-language” not defined’
   so in the backend you must set a menu to display in the location “cs-1-language”.
   That is the whole solution.
 * If you need any further help just ask.

Viewing 1 replies (of 1 total)

The topic ‘Get menu items’ is closed to new replies.

## Tags

 * [menu items](https://wordpress.org/support/topic-tag/menu-items/)

 * 1 reply
 * 2 participants
 * Last reply from: [d2.roth](https://wordpress.org/support/users/d2roth/)
 * Last activity: [10 years, 3 months ago](https://wordpress.org/support/topic/get-menu-items/#post-5823311)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
