Part 4: Neat Little Snippets of Code That Are Useful for WordPress
Okay, so here we move on to Part 4 of my “taking too long to add to this” series
I had a client this week who is an author. He does some work on practice lists, and wanted a spot to gather his writing together. The thing that he wanted was something that would count the words within his posts – since many of his lists require practice pieces to be under a certain word limit (or they just want to know how many words there are).
I found a few plugins, but when I went to test them, the word count was always off. One of my test posts was 301 words long, yet the different plugins would vary anywhere from 320 to 350 words. There were different reasons for this, and to me, it wasn’t worth troubleshooting 200 or so lines of code in the plugin to figure out why.
So I wrote my own function instead: and it took all of 10 lines (if you count the commented sections, and the two lines it took to create the function).
read more »
