How to Display Post Words Count

I don’t know why some people like to display post words count on their blog, but I personally don’t like this function. In case you are the ones like this function, then you can copy and paste the following coding to functions.php.

function wcount(){
ob_start();
the_content();
$content = ob_get_clean();
return sizeof(explode(" ", $content));
}

And then you can call the function to get the number of words of the current post:

<?php echo wcount(); ?>

Thanks to Digging Into WordPress for this excellent code.

Leave a Reply