如何在Wordpress中使用query_posts函数来过滤特定年份的帖子?如何使用query_posts过滤特定年份的帖子?
这里是我当前的代码:
<?php query_posts('cat=3&posts_per_page=10');
if (have_posts()) : while (have_posts()) : the_post();
?>
<a href="<?php the_permalink(); ?>">
<div class="testpost">
<?php the_post_thumbnail(); ?>
<h4><?php the_title(); ?></h4>
<hr class="smallblue">
<h5><?php the_time(); ?></h5>
<h6><?php echo get_the_date(); ?></h6>
</div>
</a>
<?php
endwhile; endif; >
wp_reset_query();
?>
请永远不要*使用'query_posts'(参考:stackoverflow.com/a/25589475/988246)。它应该只能被核心使用。使用诸如'WP_Query'或'get_posts'等许多其他可用函数之一,其中可以安全地使用相同的参数数组。 – indextwo