Created
September 27, 2015 22:48
-
-
Save hchouhan/3c65ef2b0934802911c4 to your computer and use it in GitHub Desktop.
Display Sub page
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
/** | |
* 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