WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] LIsting just Children pages in Side bar on parent page (7 posts)

  1. burningraven
    Member
    Posted 5 years ago #

    Hello,

    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?

  2. stvwlf
    Member
    Posted 5 years ago #

    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.
    http://www.webspaceworks.com/resources/wordpress/31/

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

  3. burningraven
    Member
    Posted 5 years ago #

    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?

  4. MichaelH
    Member
    Posted 5 years ago #

    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.

    <?php
    $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;
    ?>
  5. burningraven
    Member
    Posted 5 years ago #

    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

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

    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

  6. stvwlf
    Member
    Posted 5 years ago #

    Hi

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

    Take a look at this page
    http://codex.wordpress.org/Creating_Horizontal_Menus

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

  7. burningraven
    Member
    Posted 5 years ago #

    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,
    TIM~
    DigitalMack.com

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.