I thought this would be a simple case of following the Codex but apparently not. I'm trying to display child pages of a particular page on my homepage using a custom made template. So far I've managed to display what I want in terms of the content but I can't achieve my goal which is to display child pages of one selected page.
The page I want has an ID of 37. Yet using child_of or parent it ignores it and shows every single page. Below if my code:
<?php $home_pages = new WP_Query(array(
'sort_order' => 'DESC',
'sort_column' => 'post_date',
'post_type' => 'page',
'post_status' => 'publish'
));
if( $home_pages->have_posts() ) : ?>
<ul>
<?php $pages_per = 0;
while( $home_pages->have_posts() && $pages_per < 6 ) : $home_pages->the_post(); ?>
<li>
<?php if ( has_post_thumbnail() ) : ?>
<?php the_post_thumbnail(); ?>
<?php else : ?>
<img src="images/noimage.png" border="0" alt="No Thumbnail" />
<?php endif; ?>
<a href="<?php the_permalink(); ?>" class="title"><?php the_title(); ?></a>
<?php $pages_per++; ?>
</li>
<?php endwhile; ?>
</ul>
<?php endif; ?>
<?php wp_reset_postdata(); wp_reset_query(); ?>
The code shows six pages as instructed in the loop but doesn't seem to filter out any pages. The above example doesn't use child_of and parent but that's because I tried them and it didn't work.
For reference: https://codex.wordpress.org/Function_Reference/get_pages
get_pages()
parameters into yourWP_Query
call - so what is it what you actually want to use here?