Every so often curiosity gets the better of me and I want to find out (and publish) the total number of words I’ve put into the posts on this site (you can now see this at the top of my main archives page). Unfortunately, and quite surprisingly, each time I’ve looked for this functionality I’ve come up empty (and yes, I’m aware of MTWordStats, but it’s broken, at least for me); Movable Type still doesn’t count the words of individual entries for you, much less give you a function that returns a weblog-wide total.
I came up with a quick and very simple solution.
The first thing you’ll need to do is download and install the WordCount plugin, which returns the number of words in a given post. To get the total number of words throughout your weblog, you’ll need to run this plugin over all of your entries. To do that, insert the following code at the top of the template you’re going to use to display the total.
<MTEntries lastn=10000> <?php $tWords = $tWords + <$MTWordCount$>; ?> </MTEntries>
To display this total, place the following code in the template where you want the number shown (make sure that this code appears somewhere below the above code).
<?php echo number_format($tWords) ?>
Yep, that’s it.