Get words count of your wordpress post

January 26, 2009

How to get and display the word count of a wordpress post? The first thing to do is to create the function. Paste the following code on your functions.php file: 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; } Then open your single.php file and paste the following code: Word count:... [Read the full story]

Page 1 of 11