Posted By

telltec on 11/09/10


Tagged

pages wordpress wp nav


Versions (?)

List Child Pages


 / Published in: PHP
 

URL: http://www.tammyhartdesigns.com/tutorials/wordpress-how-to-list-child-pages-in-sidebar/

  1. <?php if ( is_page() ) { ?>
  2.  
  3. <?php
  4. if($post->post_parent)
  5. $children = wp_list_pages('title_li=&child_of='.$post->post_parent.'&echo=0'); else
  6. $children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0');
  7. if ($children) { ?>
  8.  
  9. <li>
  10. <h2>
  11. <?php
  12. $parent_title = get_the_title($post->post_parent);
  13. echo $parent_title;
  14. ?>
  15. </h2>
  16.  
  17. <ul>
  18. <?php echo $children; ?>
  19. </ul>
  20. </li>
  21.  
  22. <?php } } ?>

Report this snippet  

You need to login to post a comment.