I want to get the post count for a certain year. I've tried doing different things with this code
<?php
$count_posts = wp_count_posts();
echo $count_posts->publish;
?>
but none work. Can anyone tell me how I can do this?
I want to get the post count for a certain year. I've tried doing different things with this code
<?php
$count_posts = wp_count_posts();
echo $count_posts->publish;
?>
but none work. Can anyone tell me how I can do this?
Could use wpdb on the wp_posts table but this seems easier:
<?php
$count=0;
$my_query = new WP_Query('year=2008');
while ($my_query->have_posts()) : $my_query->the_post();
$count++;
endwhile;
echo '2008 post count is ' . $count;
?>Thanks muchly :)
You must log in to post.