Last active
August 29, 2015 14:11
-
-
Save inerds/54262cfb39e54d268ca2 to your computer and use it in GitHub Desktop.
List subpages of parent page (with parent page title) in Wordpress
This file contains hidden or 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 ( is_page() ) { ?> | |
<?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) { ?> | |
<h4> | |
<?php | |
$parent_link = get_permalink($post->post_parent); | |
$parent_title = get_the_title($post->post_parent); | |
?> | |
<a href="<?php echo $parent_link; ?>" ><?php echo $parent_title; ?></a> | |
</h4> | |
<ul class="subpages"> | |
<?php echo $children; ?> | |
</ul> | |
<?php } } ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment