How to retrieve the total word count from all posts in WordPress

Most of my own WordPress sites have been up for longer than a decade at the time of writing, and I was wondering how much I had written in that time.

Post count notwithstanding, I was interested in the total word count of my output in that period of time.

Here’s a small function that retrieves just that.

Word Count in Posts

Comments

But word count from posts is not all that a website adds up to: I have answered several thousand comments since then, and my answers may fill a whole book just by itself.

Here’s how to retrieve the comment word count for the current user:

To retrieve the total word count in all comments instead, we can do much the same thing by leaving out the user_id parameter in the above query. Subtracting the total word count from the current user word count would then reveal the comment word count that everybody else has left on a site.

Both functions work outside of The Loop.

You got to love statistics 🙂

Jay is the CEO and founder of WP Hosting, a boutique style managed WordPress hosting and support service. He has been working with Plesk since version 9 and is a qualified Parallels Automation Professional. In his spare time he likes to develop iOS apps and WordPress plugins, or draw on tablet devices. He blogs about his coding journey at http://wpguru.co.uk and http://pinkstone.co.uk.

Add your voice!