My first publicly released WordPress plugin. I’m sure there are others that do the same thing, but I wanted a stepping stone into the plugin API. This provided the perfect reason to experiment with it. An example of the output can be seen on the homepage.
The plugin consists of 4 functions:
1) askWPCount_postCount()
Returns the number of posts. No parameters.
2) askWPCount_postWordCount()
Returns the number of words in all posts.
3) askWPCount_commentCount($all_posts = true)
Returns the total number of comments. If you use this inside the WordPress loop and want to print out the number of comments for that particular post pass the function a parameter “false”. Defaults to true.
4) askWPCount_commentWordCount()
Returns the total number of words in all the comments.
Source is here: askWPCount
Does this install via the plugin manager? And can this be called from inside the main loop?
Yes. It installs like a standard plugin. Copy paste the code into a file called askWPCount.php inside your /wp-content/plugins/ folder. Activate it via the plugin manager and you should be good to go.
This can be called from the main loop and should work fine on both static and dynamic pages.