I have created custom post type. I have posted a parent post and it has a few child posts as well.
On the Parent post, I want to show its children posts.
How can I achieve it?
This would do it..
function get_child_pages() {
global $post;
$query = new WP_Query( array( 'post_parent' => $post->ID ) );
if ( $query->have_posts() ) {
echo '<ul>';
while ( $query->have_posts() ) {
$query->the_post();
//Child pages
echo '<li>' . get_the_title() . '</li>';
}
echo '</ul>';
} else {
echo 'Sorry, No posts found.';
wp_reset_postdata();
}