Posted By

sarahfrantz on 06/21/12


Tagged


Versions (?)

List Pages in Sidebar, Exclude Current Page


 / Published in: PHP
 

Based on code via Tammy Hart - slight modification to exclude current page.

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

Report this snippet  

You need to login to post a comment.