Code #14: Display Post Word Count
Hello guys, and welcome to the fourteenth day of “31 Days of Coding”. Today we’re going to talk about displaying the post word count on the single posts.
First, you need to put the following code in the functions.php file of your theme:
function wcount(){
ob_start();
the_content();
$content = ob_get_clean();
return sizeof(explode(“ “, $content));
}
Then, go to your single.php file of your theme, and in the loop, enter the following code where you want the count to display:
<?phpechowcount(); ?>
And that’s all. That will display the post word count on your theme.

