
This simple plugin will count the words in your Wordpress posts for you without having to do it manually.
Copy the code shown below. (Yes the whole thing!)
Paste it into notepad and name it as wordcount.php
<?php
/*
Plugin Name: WordCount
Plugin URI: http://andersdrengen.dk/projects
Description: Simple plugin - counts the number of words in one/all (puslished) posts and/or in one/all approved comments.
Version: 0.01
Author: Anders Holte Nielsen
Author URI: http://andersdrengen.dk
*/function WordCount($a = 0, $b = 0)
{
global $wpdb;if ($a)
{
$s = “SELECT post_content FROM $wpdb->posts WHERE post_status = ‘publish’”;
if($b)
$s = $s . ” AND ID = ‘$b’”;
}
else
{
$s = “SELECT comment_content FROM $wpdb->comments WHERE comment_approved = ‘1′”;
if($b)
$s = $s . ” AND comment_post_ID = ‘$b’”;
}$i = $wpdb->get_col($s);
$c=0;for ($j=0; $j<count($i); $j++)
$c += str_word_count($i[$j]);return $c;
}
?>
After you’ve saved it onto your desktop, upload it into your Wordpress Plugins folder. Move on to your Wordpress Admin > Plugins. Activate your Word Count plugin.
Copy and paste the following code into your index.php file where you want it to appear
(<?php echo WordCount(0, $post -> ID); ?> words in post!)
And you’re done!
Should there be any questions, please proceed here and use the contact form.

