By: Prem Tiwari | Last Updated:
Hi friend, hope you are doing good. This is very short & helpful tutorial. If you Want to get all child pages of your current page in WordPress, then copy the below code and paste the below code in your page template where you want to print the list of all child pages of your current page.
If you get any error or issues while integrating this script into your website, then feel free to put your comment in below comment section.
$args = array(
'post_type' => 'page',
'posts_per_page' => -1,
'post_parent' => $post->ID,
'order' => 'ASC',
'orderby' => 'menu_order'
$parent = new WP_Query( $args );
if ( $parent->have_posts() ) : ?>
<?php while ( $parent->have_posts() ) : $parent->the_post(); ?>
<div id="parent-<?php the_ID(); ?>" class="parent-page">
<h1><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h1>
<p><?php the_advanced_excerpt(); ?></p>
<?php endwhile; ?>
<?php endif; wp_reset_query(); ?>
Prem Tiwari is the founder of FreeWebMentor.com and also a professional developer who has vast experience in PHP and open source technologies. Apart from this, he is a blogger by hobby and also he has been a regular speaker of WordPress sessions in various IT Companies. View all posts by Prem Tiwari