Skip to content


How to pull stats from wordpress

Some nice select statments that Alex King was kind enough to show us.

Total # of posts in 2006:

SELECT COUNT(*)
FROM `wp_posts`
WHERE post_date >= '2006-01-01'
AND post_date < '2007-01-01' AND post_status = 'publish'

Total # of comments in 2006:

SELECT COUNT(*)
FROM `wp_comments`
WHERE comment_date >= '2006-01-01'
AND comment_date < '2007-01-01' AND comment_approved = '1'

Average length of posts in 2006:

SELECT AVG(LENGTH(post_content))
FROM `wp_posts`
WHERE post_date >= '2006-01-01'
AND post_date < '2007-01-01' AND post_status = 'publish'

Total length of all posts in 2006:

SELECT SUM(LENGTH(post_content))
FROM `wp_posts`
WHERE post_date >= '2006-01-01'
AND post_date < '2007-01-01' AND post_status = 'publish'

Posted in Blog Stuff.


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

You must be logged in to post a comment.