Wordpress - wp query to get child pages of current page
You have to change child_of
to post_parent
and also add post_type => 'page'
:
WordPress codex Wp_query Post & Page Parameters
<?php
$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>
</div>
<?php endwhile; ?>
<?php endif; wp_reset_postdata(); ?>
I know this is a very old question, but since I landed on it, others might as well.
Wordpress has a very simple solution for listing pages, where you can add some arguments as well.
This is all you will need to display a page's children:
wp_list_pages(array(
'child_of' => $post->ID,
'title_li' => ''
))
Look at the reference page for wp_list_pages for all options you can apply.