簡體   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