WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] in WP 2.8 - Child Pages Template no longer works (4 posts)

  1. brmecham
    Member
    Posted 5 years ago #

    I upgraded to WordPress 2.8. Now my Child Pages template doesn't correctly list the child pages.

    I made a custom page template that uses code straight from the WP Codex:

    <?php
      $children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0');
      if ($children) { ?>
      <ul>
      <?php echo $children; ?>
      </ul>
      <?php } ?>

    That's from: http://codex.wordpress.org/Template_Tags/wp_list_pages

    In 2.7.1 that child pages template worked fine, which made it so when I was viewing the parent page it would show a list of all child pages.

    For some reason now it just shows a list of my Blogroll!!!

    Any ideas on how to make this work in 2.8?

  2. BVBAccelerate
    Member
    Posted 5 years ago #

    Hey, not sure if this is exactly what you were looking for, but I had to do the same thing to my site. The following code worked for me. It shows the child pages, and if it is on the last child it will show all of the pages of the parent page. I had to combine two different kinds of old code, it's not the prettiest but gets the job done.

    <ul>
      <?php
      global $id;
      global $post;
      $navpages = wp_list_pages("title_li=&child_of=$id&depth=1&echo=0");
      if($navpages){
         echo $navpages;
      } else {
         wp_list_pages("title_li=&child_of=".$post->post_parent);
      }
      ?>
    </ul>

    Let me know if it worked for you.

  3. MichaelH
    Member
    Posted 5 years ago #

    I had no problem using the code listed by brmecham at 2.8 using the WordPress Default theme, putting the code in a Page template inside The Loop.

  4. Monika
    Member
    Posted 5 years ago #

    the original code from codex doesn't work for me too,
    if in the loop or outside -nothing ;-)

    but your code works like a charme @BVBAccelerate

    thanks a lot!

Topic Closed

This topic has been closed to new replies.

About this Topic