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