Last active
August 29, 2015 14:17
-
-
Save besimhu/be07c2c145d867c0c55e to your computer and use it in GitHub Desktop.
Show child pages of parent, or if viewing child page, it will get all pages associated with parent.
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
<aside> | |
<nav class="page-sub-navigation"> | |
<?php | |
// get child pages from post parent, otherwise | |
// get child pages from the current page being viewed, in most cases the parent | |
if ($post->post_parent) { | |
$page_list = wp_list_pages( 'title_li=&display=0&child_of='.$post->post_parent.'&echo=0' ); | |
} else { | |
$page_list = wp_list_pages( 'title_li=&display=0&child_of='.$post->ID.'&echo=0' ); | |
} | |
// if child pages exist, load them in otherwise | |
if ($page_list): | |
echo '<ul>'; | |
echo $page_list; | |
echo '</ul>'; | |
endif; | |
?> | |
</nav> | |
</aside> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment