wordpress query_posts打破特色图片

时间:2012-12-05 04:03:14

标签: php wordpress

我在网页上的WordPress网站上使用精选图片(而非帖子)。它工作正常,直到我在页面模板中使用query_posts,然后标题/品牌img将恢复为标准图像。

这是我正在使用的代码:

<?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; ?>

帖子摘录显示正常。只是query_posts打破了特色图片。

有没有人发现这个?或任何可能的解决方案?

我正在使用自定义子主题,上面是模板。

MTIA。

2 个答案:

答案 0 :(得分:1)

您可能需要在结束后添加此内容

<?php wp_reset_query(); ?>

答案 1 :(得分:0)

您尚未销毁使用query_post进行的查询。

应该使用

wp_reset_query()来重置循环。在你的情况下,应该在endwhile之后添加它。