Showing Wordcount

Want to show the number of words you’ve wrote on your blog, here’s a very simple tutorial on how to display the amount of words you’ve wrote.

1. Paste this code into your theme’s main index template where you want your word count to show.

<?php function count_words($str){
     $words = 0;
     $str = eregi_replace(" +", " ", $str);
     $array = explode(" ", $str);
     for($i=0;$i < count($array);$i++)
 	 {
         if (eregi("[0-9A-Za-z?-??-??-?]", $array[$i]))
             $words++;
     }
     return $words;
 }?>

 Word count: <?php echo count_words($post->post_content); ?&gt

Your word count will now show on your blog.