List WordPress Child Pages in Parent Page


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  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. ?>

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.