WordPress.org

Ready to get started?Download WordPress

Forums

List Child pages only NOT parent pages (4 posts)

  1. Chris Lee
    Member
    Posted 6 years ago #

    I'm currently using this snippet:

    from the codex page

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

    However it outputs parent pages as well. I just wanted the children from that particular parent? Any ideas or places where to look? I've searched vigorously as well.

  2. Chris Lee
    Member
    Posted 6 years ago #

    bump...

  3. berchman
    Member
    Posted 6 years ago #

    I am looking for a solution to this as well.

    Also, how could you display fellow children pages on a child page. In other words, how do I display the child pages brothers and sisters ONLY. No parents allowed :-)

  4. roncrump
    Member
    Posted 6 years ago #

    Well I have the following in my page template, which I think does the job (eg visit http://newenglandnomads.net/gallery/2006/ to see page "2006" containing a list of its child pages):

    <ul>
    <?php
       wp_list_pages('sort_column=menu_order&title_li=&child_of='.$post->ID.'&depth=0');
    ?>
    </ul>

    Ron.

Topic Closed

This topic has been closed to new replies.

About this Topic