WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can i echo total number of posts in last year ? I‚m writing article with stats, and want to get number of posts i published last year.

There is something here, but not for last year http://perishablepress.com/press/2006/08/28/display-total-number-of-posts/ It displays only total number of all posts

share|improve this question
up vote 4 down vote accepted

All you need to do is modify the SQL query. Using the code you linked as a base:

$numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'publish' AND year(post_date) = 2010");
if (0 < $numposts) $numposts = number_format($numposts); 

The 'AND' I added basically gives you all the posts of 2010. Change the year accordingly

share|improve this answer
"I hope I can get to the point where I give good answers myself." Welcome to that point, enjoy the view from here! – Jan Fabry Jan 2 '11 at 15:02
@Jan feels good indeed. – Manny Fleurmond Jan 2 '11 at 15:18
Thanks. I find out pluging that gives me some good stats for 2010. wordpress.org/extend/plugins/2010-summary – Саша Стефановић Jan 2 '11 at 15:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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