Created
March 23, 2013 03:56
-
-
Save spencejs/5226384 to your computer and use it in GitHub Desktop.
List Parent And Child Pages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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