List WordPress subpages and include parent


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

List WordPress subpages and include parent


Copy this code and paste it in your HTML
  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. $parent_title = get_the_title($post->post_parent);?>
  8. <li><a href="<?php echo get_permalink($post->post_parent) ?>"><?php echo $parent_title;?></a></li>
  9. <?php echo $children; ?>
  10. <?php } ?>

URL: http://wordpress.org/support/topic/including-the-parent-page-in-a-list-of-subpages

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.