您可以创建自定义WP_Query
并计算其结果。
$wp_query = new WP_Query([
\'tax_query\' => [
[
\'taxonomy\' => \'news\',
\'terms\' => $term_name,
\'fields\' => \'name\'
]
],
\'date_query\' => [
[
\'after\' => \'24 hours ago\'
]
]
]);
$number_of_posts = $wp_query->found_posts;
编辑已删除
posts_per_page
正如@birgire所建议的,论点是
found_posts
提供不考虑分页的帖子总数。