0
我想只显示我的wordpress首页上最后X天的帖子。比方说,一周,所以7天。WordPress的:循环只包括X天的旧帖子
有什么方法告诉wordpress只选择循环中最后X天的帖子?
目前,我已经通过黑客工作,但它弄乱了分页。转到下一页不会选择正确的帖子。
//Hack found on the bottom of http://codex.wordpress.org/Template_Tags/query_posts
function filter_where($where = '') {
//posts in the last 7 days
$where .= " AND post_date > '" . date('Y-m-d', strtotime('-7 days')) . "'";
}
add_filter('posts_where', 'filter_where');
query_posts($query_string);
if (have_posts()) : while (have_posts()) : the_post();
... and the usual