Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

The WordPress function wp_get_nav_menu_items returns my whole site's navigation nested and all. Now if i want to get the nav menu for one "level" of that nested navigation only, how do I do that?

share|improve this question

migrated from Feb 13 '12 at 22:56

This question came from our site for professional and enthusiast programmers.

Sorry about that... – Anton Gildebrand Feb 13 '12 at 19:52
@JonathanS. - please just flag, don't comment as well. – Kev Feb 13 '12 at 22:56
Hope this helps. Thanks… – Vasanthan.R.P Feb 14 '12 at 6:05

2 Answers 2

up vote 3 down vote accepted

Are you trying to display the posts from the top down a certain number of levels?

If so, use wp_nav_menu. It has an argument "depth" built just for this and it works painelssly.

wp_nav_menu(array('depth' => 2));


share|improve this answer

If you want to return an array of items (not output like wp_nav_menu), you can try this:

$menu_name = 'your_menu_location';
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);

    foreach ( (array) $menu_items as $key => $menu_item ) {
        if ($menu_item->menu_item_parent != 0 ) continue;
        $title = $menu_item->title;
        $url = $menu_item->url;


}   // endif has nav menu or not
share|improve this answer

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.