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 want to show only top level pages, without the dropdown. I am trying to set the depth to 0...

wp_nav_menu( array( 'theme_location' => 'primary', 'depth' => 0 ) );

But it generates:

    <li class="current_page_item">
        <a href="http://www.test.com/" title="Home">Home</a>
    <li class="page_item page-item-11">
        <a href="http://www.test.com/about/" title="About">About</a>
        <ul class='children'>
            <li><a></a></li>  <!-- All sub-pages -->
            <li><a></a></li>  <!-- I want to skip them -->

How can I list only the top level pages?

share|improve this question

Try "depth"=>1. 0 means "unlimited".

share|improve this answer
Didn't make any difference. I am using twentyeleven template... – BrunoLM Aug 7 '11 at 23:53

As a workaround I found this code:

    <li<?php if ( is_home() || is_single() || is_search() || is_archive() ) { echo ' class="current_page_item"'; } ?>><a href="<?php echo get_option('home'); ?>"><span>Home</span></a></li>

How To Highlight The Current Page In WordPress

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.