另请参见User Published Post Count
如果您有许多帖子,您可能需要使用WP Query
date_query
已从3.7版开始提供
$args = [
\'author\' => $user_id,
\'posts_per_page\' => 1, //don\'t need more
\'fields\' => \'ids\', //don\'t need more
\'suppress_filters\' => true,
\'date_query\' => [\'after\' => \'-6 months\']
];
$query = new WP_Query( $args );
$count_per_author = $query->found_posts; //how many posts match the query args
post_count
用于显示多少帖子
在日期A和日期B之间,您可以使用
\'date_query\' => [
\'after\' => \'1 January 2019\',
\'before\' => \'31 January 2019\'
],
\'inclusive\' => true,
有关详细信息,请参阅WP Codex
WP Query, inc.如何使用的示例
date
args和
inclusive
匹配精确的日期值