Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

1 Answer 1

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

 
discard

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.