Skip to content

Instantly share code, notes, and snippets.

@hchouhan
Created September 27, 2015 22:48
Show Gist options
  • Save hchouhan/3c65ef2b0934802911c4 to your computer and use it in GitHub Desktop.
Save hchouhan/3c65ef2b0934802911c4 to your computer and use it in GitHub Desktop.
Display Sub page
/**
* Display Sub Pages
*/
if ( ! function_exists( 'dreamsmedia_display_subpages' ) ) :
function dreamsmedia_display_subpages() {
$post = get_post();
$output = '';
if ( is_page() ) {
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) {
$titlenamer = get_the_title($post->post_parent);
$output .= '<div id="sidebar-subpage-list" class="widget"><h2>'.$titlenamer.'</h2>';
$output .= '<ul>';
$output .= $children;
$output .= '</ul></div>';
}
}
echo $output;
}
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment