Skip to content

Instantly share code, notes, and snippets.

@mikeselander
Created June 5, 2014 18:16
Show Gist options
  • Save mikeselander/c241d04656ce4050a9f4 to your computer and use it in GitHub Desktop.
Save mikeselander/c241d04656ce4050a9f4 to your computer and use it in GitHub Desktop.
Check to see if a page has children, and if it does, list pages out
if( !$post->post_parent ){ // If is a parent page
$parent_id = $post->ID;
} else { // If is a child
if( $post->ancestors ) {
$parent_id = end( $post->ancestors );
}
}
if ($children) {
echo "<ul class='page-children'>";
wp_list_pages( "title_li=&child_of=".$parent_id );
echo "</ul>";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment