List Current Parent and Child Pages in WordPress

November 22nd, 2011
By: Cory Mathews

Recently in WordPress I needed to create a navigation that would display a page’s parent page and all of that pages children, I am a bit rusty with PHP but here is what I got to work.

    post_parent == 0) { $pageLinkID = $post->ID; $title = $post->post_title; } else { $pageLinkID = $post->post_parent; $title = get_the_title($post->post_parent); } echo '
  • '.$title.'
  • '; $pages = get_pages('child_of='.$pageLinkID); foreach ($pages as $p) { echo '
  • '.$p->post_title.'
  • '; } ?>

If you need to order the posts by the order value change the $pages = Line to

$pages = get_pages('child_of='.$pageLinkID.', 'sort_column' => 'menu_order', 'sort_order' => 'asc');