Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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:

<ul>
    <li class="current_page_item">
        <a href="http://www.test.com/" title="Home">Home</a>
    </li>
    <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 -->
        </ul>
    </li>
</ul>

How can I list only the top level pages?

share|improve this question
add comment

2 Answers

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
add comment

As a workaround I found this code:

<ul>
    <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>
<?php
    wp_list_pages('title_li=&depth=1');
?>
</ul>

How To Highlight The Current Page In WordPress

share|improve this answer
add comment

Your Answer

 
discard

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.