I need some kind of plugin (if it exists) or a wp query which would display number of posts published within a certain time range.

For example:

I need to know how many posts have been published since 2015-06-01 until now -- 2015-06-27.

I really hope someone could help me out.


  • Please elaborate your question and show us what have you tried so far. Jun 27, 2015 at 10:33

2 Answers 2


You can fetch the record using bellow query

$posts= get_posts(array(
            'numberposts' => -1,
            'post_status' => 'publish',
            'orderby' => 'date',
            'order'   => 'DESC',
            'date_query'    => array(
                'column'  => 'post_date',
                'after'   => '-7 days'  // -7 Means last 7 days 
echo count($posts);

If you want to get last 6 month the use -6 Months

  • Thanks. But unfortunately I'm not a developer, so how should I display the final number? Because when I type echo $posts; It just gives me "Array". Thank you in advance. :)
    – IGNAS
    Jun 27, 2015 at 10:21
  • Ok so you need to use the count function let me update code
    – Mitul
    Jun 27, 2015 at 10:24
  • I have updated code let me know if you have any prolem
    – Mitul
    Jun 27, 2015 at 10:25
  • It works great. That's amazing. Thank you very much! :)
    – IGNAS
    Jun 27, 2015 at 10:27
  • @IGNAS Don't forget to mark it as the correct answer.
    – Vlad Olaru
    Jan 28, 2018 at 18:12

see also User Published Post Count

if you've got many posts, you may want to use WP Query

date_query has been available since version 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 is used for how many posts are displayed

for between date A and date B, you can use

'date_query' => [
    'after' => '1 January 2019',
    'before' => '31 January 2019'

'inclusive' => true,

see the WP Codex for more details on WP Query, inc. examples of how to use the date args and inclusive to match exact date values

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.