It is a very common need in WordPress environment to count and display total number of posts for a required time parameter like month, day, week, year etc.

Here we are going to share a code snippet that will help you to achieve this task easily. This code will help you to count total number of posts for the current month and you can modify it according to your need very easily,

<?php
/** WP Query Arguments */
$today = getdate();
$args = array(
	'year' => $today['year'],
	'monthnum' => $today['mon'],	
);

/** WP Query */
$the_query = new WP_Query( $args );

/** Output */
echo 'Total Number of Posts For Current Month: ' . $the_query->post_count;
?>

Source: