List subpages for subnavigation

Hi everyone,

Hopefully someone will help me out here!

I’m trying to list the sub pages of a parent page on the parent page and its subpages, as I want this to be separate from the main navigation.

I’m using one custom menu (the basic primary_navigation), in the past I have used wp_list_pages and a snippet from the codex to do so (php is not my strength!) but this is not working correctly.

Ill buy you a cookie (or a beer!) if you can help me out!


Is this what you mean:

Look just under the page title, you’ll see the subpages listed out for that main page on each subpage

Hi, yes this looks like what I’m after. Got any snippets you would care to share?

  1. just an example of a div you could insert the nav into

php wp_nav_menu(array( ‘depth’ => ‘2’ )); ?>

  1. example css, this is css from the example site above. This solution is really just calling out the main nav again and then using css to show what you want it to. You should be able to take it from here. Any questions let me know or refer back to the site example

.breadcrumbs ul > > a {display: none;}
.breadcrumbs ul > > ul.dropdown-menu> li {list-style: disc; height: 100%;}
.breadcrumbs ul > > ul.dropdown-menu> li > a {padding: 0; line-height: inherit;}
.breadcrumbs ul > > ul.dropdown-menu {float: none; display: block; background: none; border: medium none; border-radius: 0 0 0 0; box-shadow: none; display: block; top: 0; width: 100%; height: 100%;}
.breadcrumbs ul > > ul.dropdown-menu > .active > a, .breadcrumbs ul > > ul.dropdown-menu > .active > a:hover, .breadcrumbs ul > > ul.dropdown-menu > .active > a:focus {background: none;}
.breadcrumbs ul > > ul.dropdown-menu > li > a:hover, .breadcrumbs ul > > ul.dropdown-menu > li > a:focus {background: none; color: #000;}

The following snippet grabs the post parent and then lists out the parent as well as their subpages.


About page

  • Our story

  • Careers

  • Contact us

    <?php if($post->post_parent) $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0"); else $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0"); if ($children) { ?>
        <?php echo $children; ?>
    <?php } ?>

EDIT: Got all garbled up top. Here’s a gist of the code:

Is this grabbing all the sub-pages associated with the parent page, or is it reflecting the main navigation showing only the subpages listed in the primary menu?

Above is what I used to show only the sub pages listed in the primary menu for the site

Sorry I’m not sure what you’re asking. He asked for something separate from the primary navigation that will list the parent link and all relevant subpages. That’s what the snippet I posted does. It does this whether you’re on the parent page or one of the subpages. It has nothing to do with the main navigation.



Thanks for all the replies, been too busy to reply!

I “was” looking for the sub items of the custom menu rather than sub pages as set in the page edit screen, sorry if I didn’t make that clear.