Posted By

raz on 01/26/11


pages list wordpress subpages Parent

Versions (?)

Who likes this?

1 person have marked this snippet as a favorite


List WordPress subpages even if on a subpage

 / Published in: PHP


his code will show the child pages, and only the child pages, when on a parent or on one of the children. This code will not work if placed after a widget block in the sidebar.

  1. <?php
  2. if($post->post_parent)
  3. $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
  4. else
  5. $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
  6. if ($children) { ?>
  7. <ul>
  8. <?php echo $children; ?>
  9. </ul>
  10. <?php } ?>

Report this snippet  

You need to login to post a comment.