This seems like it should be easy to do, but I've not been able to find or work out a solution.

I'm using the Starkers theme and Wordpress 3.0.4, and my site auto-generates its navigation as per normal. I would like however the navigation to only show the top level pages, i.e. not display links to any pages that are children of other pages.

This is the code I am currently using.

<?php wp_nav_menu( array( 'container' => 'nav', 'fallback_cb' => 'starkers_menu',
'theme_location' => 'primary' ) ); ?>

I would like to hide the child links programmatically, but I am prepared to use CSS if someone can instead advise how to assign specific classes to the child links.

Thanks in advance for any help.

**edit 2**

I've tracked down the actual function I am using, called starkers_menu (below). However adding depth to this, or even removing the other exclusions and just using depth doesn't work either:

function starkers_menu() {
    echo '<nav><ul>';
    echo '</ul></nav>';
  • Where does 'fallback_cb' => 'starkers_menu' come from? I assume you use theme callled Starkers? I can't find such function or any calls to it there.
    – Rarst
    Jan 27, 2011 at 14:56
  • Yes, I'm using the Starkers theme.
    – ajcw
    Jan 27, 2011 at 15:33
  • 'fallback_cb' => 'starkers_menu' does not exist in the most recent version of Starkers, so can only assume you're running an older version, can you track down that function? Perhaps add a copy of the function into the question..
    – t31os
    Jan 27, 2011 at 17:49
  • Good point t31os, I've added it now.
    – ajcw
    Jan 28, 2011 at 11:10

1 Answer 1


Had you tried depth argument (see wp_nav_menu() documentation)?

Also do I understand right that you do not setup menu manually and let theme generate it with custom callback that you have in your code?


Same answer - try depth argument, only this time in wp_list_pages() call in starkers_menu() function. It should work, unless that function is never processed and not available at the time of menu running.

Do you use latest version of theme?.. If not consider updating.

  • Thanks for your reply Rarst - I have tried depth with no luck - see my edit in the question. And yes, I am using the theme's generated menu, I have not manually changed it yet.
    – ajcw
    Jan 27, 2011 at 14:44
  • Right, I've just looked more closely and the problem was solved using depth. I hadn't noticed however that the page I was trying to hide had become unattached from it's parent, and hence was a top-level page. Doh! Thanks for everyone's help.
    – ajcw
    Jan 28, 2011 at 11:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.