繁体   English   中英

如何根据评论数和不到一年的历史来查询wordpress帖子?

[英]How do I query wordpress posts based on comment count and less than one year old?

我有以下代码,该代码返回包含最多评论的帖子:

$popPosts = new WP_Query();
$popPosts->query('ignore_sticky_posts=1&posts_per_page='.$posts.'&orderby=comment_count'); 

我需要对其进行更改,以便它不会返回任何超过一年的文章。 有人可以提供解决方案吗?

谢谢!

这样的事情可能会有所帮助:

$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 (在“日期参数”下)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM