Counting things in WordPress

A couple of MySql queries to count up your 2006 blog stats (as I did on my personal blog).

Count the number of posts since…

select count(*) from wp_posts
where
post_status = ‘publish’
and wp_posts.post_date >= ‘2006-01-01’

Count the post with the most comments since…

select wp_posts.ID, count(*) as wpc, wp_posts.post_title, wp_posts.post_date from wp_comments, wp_posts
where
wp_comments.comment_approved = ‘1’
and wp_comments.comment_post_ID = wp_posts.ID
and wp_posts.post_date >= ‘2006-01-01’
group by comment_post_ID
order by wpc desc