Posted By

fidiz on 01/03/11


Tagged

wordpress


Versions (?)

List WordPress Child Pages in Parent Page


 / Published in: PHP
 

URL: http://www.martin-gardner.co.uk/how-to-list-wordpress-child-pages-only-on-that-parent-page/

  1. <?php if ( is_page() ) {
  2. if($post->post_parent)
  3. $children = wp_list_pages('sort_column=menu_order&title_li=&child_of='.$post->post_parent.'&echo=0');
  4. else
  5. $children = wp_list_pages('sort_column=menu_order&title_li=&child_of='.$post->ID.'&echo=0');
  6. if ($children) {
  7. ?>
  8. <div class="sidebar">
  9. <h2>Sub-pages of Current Page</h2>
  10. <ul>
  11. <?php echo $children; ?>
  12. </ul>
  13. </div>
  14. <?php
  15. } // End If Post
  16. } // End if is page
  17. ?>

Report this snippet  

You need to login to post a comment.