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 🙂

About Jay Versluis

Jay is a medical miracle known as a Super Survivor. He runs two YouTube channels, five websites and several podcast feeds. To see what else he's up to, and to support him on his mission to make the world a better place, check out his Patreon Campaign.

Add your voice!