WordPress get all subpages of current page’s parent page

Home » Blog » WordPress get all subpages of current page’s parent page

Following code will display all the subpages of same parent page. also displays the subpages of current page if it is not a subpage.

<?php
  if($post->post_parent) {
  $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0$sort_column=menu_order");
  $title_heading = get_the_title($post->post_parent);
  }

  else {
  $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
  $title_heading = get_the_title($post->ID);
  }
  if ($children) { ?>

  <h2> <? echo $title_heading ?> </h2>
  <ul>
  <?php echo $children; ?>
  </ul>

<?php } ?>

3 Comments on "WordPress get all subpages of current page’s parent page"

  1. David says:

    Superbly designed website!!!
    Very impressed.

    Reply →
  2. Kat says:

    Awesome! Thank you. Searched for this for a bit…

    Reply →

Got something to say? Go for it!

How to remove the http://t.co/XhUQ8T6p link from Login / Register Page: On self hosted wordpress blogs wordpress ... http://t.co/LWDOuEfq - 1 week ago