Skip to content

Instantly share code, notes, and snippets.

@krazylegz
Forked from nicksatkovich/gist:1444526
Created December 7, 2011 20:43
Show Gist options
  • Select an option

  • Save krazylegz/1444557 to your computer and use it in GitHub Desktop.

Select an option

Save krazylegz/1444557 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');
}
if ($children):
$parent_title = end(get_post_ancestors($post));
?>
<h2><?php echo get_the_title($parent_title); ?></h2>
<ul>
<?php echo $children; ?>
</ul>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment