How To Display Post Word Count in Wordpress

December 23, 2009 by admin  
Filed under How-To

How To Display Post Word Count in Wordpress. So you are here in search to display how many words are there in particular post, so you are at right place the below trick will match your needs. Here is some code which you need to add in function.php file of you wordpress themes to display the actual posts word count.

Here are step by step guide to display word count.

  1. Open function.php
  2. Add the following code in it before closing tab “?>”
  3. function wcount(){
        ob_start();
        the_content();
        $content = ob_get_clean();
        return sizeof(explode(" ", $content));
    }
    
  4. Add the following line where you want to display word count, generally in index.php or single.php
  5. <?php echo wcount(); ?>
    
  6. Its Done.. Check the post.

If this won’t work then comment , will try to solve the error.

Source : Wprecipes