how to: exclude blockquote text from wp word count statistics

how to: exclude blockquote text from wp word count statistics

there are many wordpress plugins that count the written words out there, and my plugin of choice is WP Word Count because of its simple, straight-forward overview page, which includes total counts as well as numbers by month and author.
however, it’s not always desirable to include everything in those counts – e.g. if you hire writers and get billed by the word, you may want to exclude blockquotes.

the following little code modification achieves just that:

you can either open the plugin’s php-file in a text-editor, or (if you don’t have ftp access) use wordpress’ plugin editor.
find the line called “function bjl_word_counter” (in V1.4: line 184), and add/modify the bold segments.

function bjl_word_counter($content)
{
//mn edit: exclude everything within blockquotes!
$mncontent = ereg_replace('\<blockquote\>.*\<\/blockquote\>','',$content);
// THIS IS THE SAME METHOD USED BY TD WORD COUNT (http://www.tdscripts.com/wp/tdwordcount/)
return str_word_count(strip_tags($mncontent));
}

tadah!
now, all the text that is blockquoted is ignored for the word count.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.