Does anyone know how I could count the number of post per month. I looked and searched around, but I could not find anything. Thanks.
Does anyone know how I could count the number of post per month. I looked and searched around, but I could not find anything. Thanks.
Try:
<?php
$current_month = date('m');
$current_year = date('Y');
$countposts=get_posts("year=$current_year&monthnum=$current_month");
echo 'the count of posts' . count($countposts);
?>
See:
query_posts Time parameters
get_posts()
Stepping Into Template Tags
Stepping Into Templates
Template Hierarchy
Thanks, but I figured it out another way. I was just creating an Archive page and I wanted to output the number of posts in each month. After reading some more source code & documentation, I found that all I had to do was add the argument "how_post_count=1" to the command "wp_get_archives('type=monthly')". If you or anyone else is curious, this is what i have now:
<?php wp_get_archives('type=monthly&show_post_count=1'); ?>
Thanks MichaelH.
This topic has been closed to new replies.