As the year is coming to a close a lot of sites are creating year in review style posts. I love these because I find it interesting how my stuff compares to them and I try to find little nuggets of information on what I should be doing better.

Alex King has been doing this for the past 9 years and has created a little gist for generating a lot of useful stats.

To take this a step further I wanted to count the total words I published for the year and I put together a little script if you’d like to do the same:


<?php
$words = 0;
$posts = query_posts([
'posts_per_page' => –1,
'year' => '2014',
]);
foreach ($posts as $post) {
$words += str_word_count($post->post_content);
}
echo 'Total Words: '. number_format($words);
?>

Granted this method is simple and the php function str_word_count is not entirely accurate. If you’d like to get fancy a Word Stats plugin does exist but I found that it wouldn’t work at all with the current version.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s