Title: Word count plugin?
Last modified: August 18, 2016

---

# Word count plugin?

 *  [dreamsindigital](https://wordpress.org/support/users/dreamsindigital/)
 * (@dreamsindigital)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/word-count-plugin/)
 * Does anyone know of a plugin that will let me see the number of words I’ve typed
   as I am writing a new post? That would be useful to me.
 * Thanks

Viewing 7 replies - 1 through 7 (of 7 total)

 *  [tsguitar](https://wordpress.org/support/users/tsguitar/)
 * (@tsguitar)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/word-count-plugin/#post-431595)
 * It’s not a plugin (though maybe someone could package it up so it is), but here’s
   what you need:
    [http://wordpress.org/support/topic/43544?replies=5](http://wordpress.org/support/topic/43544?replies=5)
 * I’ve been using it since then (March 2006) and it works fine.
 *  Thread Starter [dreamsindigital](https://wordpress.org/support/users/dreamsindigital/)
 * (@dreamsindigital)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/word-count-plugin/#post-431612)
 * Thanks, but I’m having a little problem. I’m pasting this after the div:
    ` <?
   php $countpost = $post->post_content; $countpost = preg_replace('/s+/', ' ', 
   strip_tags($countpost)); // remove white space and html $words = ((count(explode("",
   $countpost)) + count(explode(".r",$countpost)))-1); // count spaces and periods
   if ($words == 1) { echo "<p class="note">Post length: ~ $words word "; } else{
   echo "<p class="note">Post length: ~ $words words "; } ?>  …but I get an error
   that says “Parse error: syntax error, unexpected T_STRING, expecting ‘,’ or ‘;’
   in /home/allen/public_html/behindthedreams/wp-admin/edit-form-advanced.php on
   line 163”
 * Any ideas? Thanks
 *  [tsguitar](https://wordpress.org/support/users/tsguitar/)
 * (@tsguitar)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/word-count-plugin/#post-431654)
 * I’ll try again, but with a pastebin this time:
    [http://pastebin.ca/121545](http://pastebin.ca/121545)
 * A few bits of code got lost in translation to the forum here, a common problem.
   Give that a shot. It should work perfectly as it’s the exact code in my admin
   page. Let me know.
 *  Thread Starter [dreamsindigital](https://wordpress.org/support/users/dreamsindigital/)
 * (@dreamsindigital)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/word-count-plugin/#post-431656)
 * Thanks! It works.
 *  Thread Starter [dreamsindigital](https://wordpress.org/support/users/dreamsindigital/)
 * (@dreamsindigital)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/word-count-plugin/#post-431838)
 * I came across this word count plugin that’s easier than inserting the code, and
   also gives other information. Although, it counts hyperlinks as well so it’s 
   kind of in accurate. Maybe someone can mode it.
 * [http://flagrantdisregard.com/wordstats/](http://flagrantdisregard.com/wordstats/)
 *  [tsguitar](https://wordpress.org/support/users/tsguitar/)
 * (@tsguitar)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/word-count-plugin/#post-431843)
 * Ok, I got how to make the word count a bit more accurate. My code is far more
   accurate than theirs when counting words in hyertext. Just as it should be, `
   <h4>Title of Movie</h4>` is 3 words with mine, but 9 with Word Stats. It’s easy
   to modify their code, though, and it even looks like they knew they’d have to
   do this sooner or later because they already began the process to make it happen.
 * Open `wordstats.php` and look for the comment “// What about dashes (vs. hyphens).”
   The line right after that is commented out. Take the comments off (delete the“//”)
   and make that line read:
    `return(count(preg_split('/s+/', trim($this->text))));`
 * If someone can modify that code to not count things between brackets, that’ll
   do it. As it stands, `<a href=...` counts as 2 words because my code counts the
   spaces. If it can somehow split by spaces (`/s+/`) AND ignore things brackets(`((
   >)|(<))`), that would be perfect. I don’t know regular expressions enough to 
   know how to do both of those things. Still, this is getting better.
 *  [sabat](https://wordpress.org/support/users/sabat/)
 * (@sabat)
 * [18 years, 11 months ago](https://wordpress.org/support/topic/word-count-plugin/#post-431959)
 * What you need to do is to substitute out anything between < and > first, and 
   then do the split and word count:
 * return(count(preg_split(‘/( |\n)/’, preg_replace(‘/<+?>/’, ”, trim($this->text)))));
 * BUT, having checked what $this->text actually produces, I don’t see any bracketed
   code anyway. So I’m not sure this is necessary.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Word count plugin?’ is closed to new replies.

## Tags

 * [count](https://wordpress.org/support/topic-tag/count/)
 * [word](https://wordpress.org/support/topic-tag/word/)

 * 7 replies
 * 3 participants
 * Last reply from: [sabat](https://wordpress.org/support/users/sabat/)
 * Last activity: [18 years, 11 months ago](https://wordpress.org/support/topic/word-count-plugin/#post-431959)
 * Status: not a support question

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
