Is there a way to find out how many words I’ve written in my blog?
This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.
The active forums are here.
March 20, 2011 9:44pm
Subscribe [3]#1 / Mar 20, 2011 9:44pm
Is there a way to find out how many words I’ve written in my blog?
#2 / Mar 21, 2011 4:37pm
Hi, jretzer!
You would need to run a query through this, along with some PHP, that would bring together the content from your custom fields and count the words. I thought there was a wiki entry on it back in 2005-6, but I can’t find it now, and don’t see anything on Devot-ee. So this would need to be a custom solution.
#3 / Mar 21, 2011 4:44pm
Hi jretzer,
This is more appropriate for the CodeShare Corner, so moving it over there, but I’ll take a crack at it!
ExpressionEngine includes a Query module that lets you run arbitrary queries on your database. Make sure that module is installed first.
Then, you need to look at your database to determine which field your blog post bodies are stored in. You should be able to tell this easily by looking at your “exp_weblog_data” table. One of those columns, named “field_id_xx” will be for your blog body field. Say you find that it’s field_id_1.
You’d drop this into a template:
{exp:query sql="SELECT SUM(LENGTH(REPLACE(REPLACE(field_id_1,' ',' '),' ',' ')) - LENGTH(REPLACE(field_id_1,' ',''))+1) AS word_count
FROM exp_weblog_data"}
Found {word_count} words
{/exp:query}This isn’t a query I’d put on every page as it’s pretty intensive, but it should do the trick.
#4 / Mar 21, 2011 7:13pm
Might want to change the query above to say exp_channel_data instead of exp_weblog_data if doing this on a 1.x install too 😉
Nice little query there Brandon.
Best wishes,
Mark
#5 / Mar 21, 2011 7:26pm
It works!
Found -5857026 words
Thanks!
Actually—5 million words seems excessive ... my blog as 6,500 posts ... so this 5 million must include double counts for posts in categories and such.
#6 / Mar 21, 2011 9:50pm
Mark, I think you mean 2.x? 😊 This was originally in the 1.x forum.
jretzer, that works out to about 900 words per post… does that seem inaccurate? There shouldn’t be any duplicates counted with that query. It seemed OK with my test data, at least.
#7 / Mar 21, 2011 10:30pm
I just counted the words in my last ten posts: 2857, so an average of say, 300 a post. Way shorter than 900. Something’s not quite right ...
#8 / Mar 22, 2011 8:17am
Mark, I think you mean 2.x? 😊 This was originally in the 1.x forum.
Hmm that’s weird. I could swear that it did say that as I always check my posts after I’ve posted them. Must have missed that one.
Sorry didn’t know this was in the 1.x forum originally. I only saw it in the CodeShare corner. Perhaps there should be something in these forums on perhaps the top post to mention that?