How to: WordPress Count Words in a Post

Here is sample code I use to count words in a post ( I found it somewhere while searching something else). Put the code in functions.php (no need to write plugin)

You can call blog_post_wordcount() from template. Following code will display ad only if a post has more than 100 words: