[英]How do I query wordpress posts based on comment count and less than one year old?
I have the following code, which returns the posts with the most amount of comments: 我有以下代码,该代码返回包含最多评论的帖子:
$popPosts = new WP_Query();
$popPosts->query('ignore_sticky_posts=1&posts_per_page='.$posts.'&orderby=comment_count');
I need to alter it so that it doesn't return any articles that are more than a year old. 我需要对其进行更改,以便它不会返回任何超过一年的文章。 Can anybody offer a solution?
有人可以提供解决方案吗?
Thanks! 谢谢!
Something like this might help: 这样的事情可能会有所帮助:
$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 );
As seen here: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters (under "Date Parameters") 如此处所示: http : //codex.wordpress.org/Class_Reference/WP_Query#Parameters (在“日期参数”下)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.