如何在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