Add a Character Counter to the WordPress Excerpt Box

Spread the love

Adding a Character Counter to Excerpts

When I first started using WordPress and writing blogs, I was forever having to edit custom excerpts on posts because they were always too long for the space.

In searching for a solution, I came across this fantastic snippet at Github. Simply add the following code to your functions.php files, or create your own plugin for it if you prefer.

 

And here’s what it looks like in the backend of WordPress when you’re editing posts:

You can change the maximum number of characters in any excerpt by changing the “$limit = 150;” in the code.

Why Would You Need a Character Counter?

Many themes have a specific requirement for how long excerpts should be. If you want your excerpts to display nicely without being cut off mid-sentence, having a character counter allows you to ensure your excerpt length is under a certain number of characters.

Do you use custom excerpts on your site? What other kinds of scripts or WordPress hacks would you like to see on my blog? Let me now in the comments below.