Skip to content

Instantly share code, notes, and snippets.

@spencejs
Created March 23, 2013 03:56
Show Gist options
  • Save spencejs/5226384 to your computer and use it in GitHub Desktop.
Save spencejs/5226384 to your computer and use it in GitHub Desktop.
List Parent And Child Pages
<?php
if($post->post_parent)
$children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
else
$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
if ($children) { ?>
<ul class="sectionlist">
<?php
$parent_title = get_the_title($post->post_parent);?>
<li class="page_item <?php
global $post; // if outside the loop
if ( is_page() && $post->post_parent ) {
// This is a subpage
} else {
echo 'current_page_item';// This is not a subpage
}
?>"><a href="<?php echo get_permalink($post->post_parent) ?>"><?php echo $parent_title;?></a></li>
<?php echo $children; ?>
</ul>
<?php } ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment