Support » Themes and Templates » LIsting just Children pages in Side bar on parent page

  • Resolved burningraven



    I am designing a site were I would like to have the children pages listed on/in the side bar on the the parents page and only on the individual parents page.

    Example – lets say this is my site map (* = parents page | o = child page) .

    * Africa
    o Cameroon
    o Lesotho
    o Swaziland
    o Togo
    * South America
    o Argentina
    o Brazil
    o Chile

    When you are on the Africa page, Cameroon, Lesotho, Swaziland, or Togo page -you see the children links for Africa only and not South America

    Like wise If you were on the South America, Argentina, Brazil or Chile page you would only see the children pages for South America and not the children pages for Africa nor the Africa page.

    Does this make sense? any solutions?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Take a look at this plugin, which does what you want. It does require changing a few lines of code in your template – read the plugin instructions.

    It works fine in 2.7.1 even though it may say it is not tested up through that version.

    HI stvwlf,

    Thanks for the link.

    The site I am designing will be more of a CMS based then a blog. So it will be built with more pages them Categories (as the plug uses). I woudl like to list the child pages on each sub page.

    One idea I was thinking of trying was just different page templates for each main page group. Then how calling the children pages the page template code.

    Any ideas?

    For use in sidebar, display only top level pages, but when view page that has children or is a child show only children of that parent
    When visit main page, all top level pages are listed in the sidebar.
    When click on a top level page with no children, all top level pages are listed.
    When click on a top level page with children, just the children pages are listed.
    When click on a children page, just the children of that parent are listed.

    $output = wp_list_pages('echo=0&depth=1&title_li=<h2>Top Level Pages </h2>' );
    if (is_page( )) {
      $page = get_query_var('page_id');
      if ($post->post_parent) {
        $page = $post->post_parent;
      $children=wp_list_pages( 'echo=0&child_of=' . $page . '&title_li=' );
      if ($children) {
        $output = wp_list_pages ('echo=0&child_of=' . $page . '&title_li=<h2>Child Pages</h2>');
    echo $output;

    WOW! Thanks Michael H!

    Thats just the sort of code snipet I was looking for.

    One last thing.

    Sora of minor, but when I run this code it will list the menu items as

    <li>item 1</li>
    <li>item 2</li>
    <li>item 3</li>

    Do you happen to know the CSS or twist I put on this code to format the ul and list itmes horizontal instead of vertical?

    Again 100% thanks!

    Cheers mate


    To make a horizontal menu either make the li tags display:inline or float: left

    Take a look at this page

    Sorry about suggesting a category plugin before. I had a momentary brain meltdown and confused what you were looking for.

    lol stvwlf,

    Every day in my world is a momentary brain meltdown so no worries at all brother.

    Thanks for the pointer as well, this was the answer I was looking for.

    Cheers and best regards,

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘LIsting just Children pages in Side bar on parent page’ is closed to new replies.