Skip to content

Instantly share code, notes, and snippets.

@nicksatkovich
Created December 7, 2011 20:36
Show Gist options
  • Select an option

  • Save nicksatkovich/1444526 to your computer and use it in GitHub Desktop.

Select an option

Save nicksatkovich/1444526 to your computer and use it in GitHub Desktop.
<?php
if (!$post->post_parent) {
$children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0');
} else {
$p = end(get_post_ancestors($post->ID));
$children = wp_list_pages('title_li=&child_of='.$p.'&echo=0');
}
?>
<?php
if ($children) {
$parent_title = end(get_post_ancestors($post));
?>
<h2><?php echo get_the_title($parent_title); ?></h2>
<ul>
<?php echo $children; ?>
</ul>
<?php } ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment