0
votes

I'm using featured images on a WordPress site on pages (not posts). It works fine until I use query_posts in a page template and then the header/branding img reverts to the standard images.

This is the code I'm using:

<?php 
query_posts(array('category_name'=>'news-and-features', 'posts_per_page' => 2 ));
while (have_posts()) : the_post(); ?>
  <div class="single-post">
    <h3><a href="<?php echo get_permalink(); ?>"><?php the_title();?></a></h3> 
    <?php the_time('D jS M, Y') ?>
    <?php the_excerpt();?>
</div>
<? endwhile; ?>

The post excerpts display fine. It's just that the query_posts breaks the featured image.

Has anyone found this also? Or any possible solutions?

I am using a custom child theme and the above is in a template.

MTIA.

2

2 Answers

1
votes

you might need to add this after the endwhile

<?php wp_reset_query(); ?>
0
votes

You have not destroyed the query you made with query_post.

wp_reset_query() should be used to reset the loop. It should be added after your loop, in your case, after the endwhile.