查看已添加到WP 3.7中的date\\u查询参数WP_Query#Date_Parameters 以及author parameter.
根据需要组合这两个参数,以查询作者在给定时间内创建的所有帖子:
<?php
$args = array(
\'posts_per_page\' = -1, // get all posts
\'author\' => get_the_author_meta( \'ID\' ), // from this author ID
\'date_query\' => array( // in the last week
array(
\'year\' => date(\'Y\'),
\'week\' => date(\'W\'),
),
\'fields\' => \'ids\' // only return an array of post IDs
),
);
$results = new WP_Query( $args );
echo count( $results ); // display the number of results
echo $results->found_posts; // display the number of results
?>
Edit: 我根据@birgire的输入更新了这个答案,以便表现得更好。