WordPress.org

Support

Support » How-To and Troubleshooting » Display list of Child pages

Display list of Child pages

  • 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 } ?>
Viewing 1 replies (of 1 total)
  • 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
Viewing 1 replies (of 1 total)
  • The topic ‘Display list of Child pages’ is closed to new replies.