👉 Divi Builder drag/drop page builder for WordPress
When it comes to writing great content, word count is not the biggest factor. At the same time, you don’t want to have posts that are too short or long. The good news is you can write PHP and JavaScript code to track word count in your posts or pages in real-time.
This function enqueues a JavaScript file that monitors your block editor’s content. It calculate the word count by splitting the text into words and filtering out empty strings. A progress bar and an info label are dynamically added to the editor sidebar. Here is the JavaScript function you need:
Â
More WordPress reading: