我有以下代码,它返回评论量最多的帖子:
$popPosts = new WP_Query();
$popPosts->query('ignore_sticky_posts=1&posts_per_page='.$posts.'&orderby=comment_count');
我需要更改它,以便它不会返回任何超过一年的文章。任何人都可以提供解决方案吗?
谢谢!
答案 0 :(得分:0)
这样的事情可能有所帮助:
$args = array(
'date_query' => array(
array(
'column' => 'post_date_gmt',
'after' => '1 year ago',
)
),
'posts_per_page' => $posts,
'ignore_sticky_posts' => 1,
'orderby' => 'comment_count'
);
$query = new WP_Query( $args );
如此处所示:http://codex.wordpress.org/Class_Reference/WP_Query#Parameters(在“日期参数”下)