On my front page of the site (which uses page.php template) I want to display a list of child pages from parent with id 19, I want to display a featured image, title of a page and a specific custom field of each page.
For this purpose I tried to use wp_query but it does not seem to work. I looked into WordPress codex where one of the parameters to use with wp_query is:
post_parent (int) - use page id. Return just the child Pages.
I don't understand why my code doesn't work. I am using:
$query = new WP_Query('post_parent=19'); and the loop:
while ( $query->have_posts() ) : $query->the_post(); ?>
<?php the_post_thumbnail( 'small' ); ?>
<?php the_title(); ?>
<?php echo get_post_meta($post->ID, 'intro', true); ?>
<?php endwhile;
// Reset Post Data
wp_reset_postdata();
?>
I have a parent page with Id 19 set up and relevant subpages. The query above doesn't not bring any data.
On the same page I also have another loop like this (before above one):
<?php if ( have_posts() ) : ?>
<div id="welcome">
<?php while ( have_posts() ) : the_post(); ?>
<h1><?php the_title(); </h1>
<?php the_content(); ?>
<?php endwhile; ?>
<?php wp_reset_query(); wp_reset_postdata(); ?> </div>
<?php endif; ?>
I wonder if there is a conflict? Or what is that that I am doing wrong? Am I missing something? Your help would be really appreciated.