WordPress.org

Ready to get started?Download WordPress

Forums

Display list of Child pages (2 posts)

  1. Red Deer Web Design
    Member
    Posted 2 years ago #

    Hey guys, hoping to find a little help. I've been reading the codex: http://codex.wordpress.org/Template_Tags/wp_list_pages#List_Sub-Pages

    I have the code to display child pages of the parent, however I DO NOT want it to display the decedent of a child page when visiting that child page.

    Right now I am getting the decedent...

    <?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) { ?>
      <ul>
      <?php echo $children; ?>
      </ul>
      <?php } ?>
  2. vtxyzzy
    Member
    Posted 2 years ago #

    Mostly a guess, but try changing this:

    if($post->post_parent)
      $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
      else

    to this:

    if($post->post_parent)
      $children = '';
    else

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.