List subpages of current page


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



Copy this code and paste it in your HTML
  1. function list_sub_pages () {
  2. global $wp_query;
  3. if( empty($wp_query->post->post_parent) ) {
  4. $parent = $wp_query->post->ID;
  5. echo "<h3>".get_the_title($parent)."</h3>";
  6. } else {
  7. $parent = $wp_query->post->post_parent;
  8. echo "<h3><a href='".get_permalink($parent)."'>".get_the_title($parent)."</a></h3>";
  9. }
  10. echo '<ul>';
  11. wp_list_pages("title_li=&child_of=$parent" );
  12. echo '</ul>';
  13. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.