September 7th, 2007

Word Count Plugin for WordPress

Category: wordpress, 推介, 插件, 统计, Author: 阿七, Popularity: 11% [?]


Falling under the “if you don’t like what’s out there, do it yourself” category, I’ve written my first real WordPress plugin. (I created a plugin once to do some very customized behavior for a consulting client, but it was more some added functionality to help a custom-designed template that I’d designed. This is my first standalone general use plugin.)

What does it do? Well very very simply, it allows you to calculate and post Word Count information about a post. Specifically, it is meant to be used somewhere inside “The Loop” in a WordPress template page. You will probably want to include it in that typical “Written by John Smith on January 3rd, 2007″ summary line that precedes the_content() or you might be clever and include it in the “more” line.

To use it, simply include the mtw_wordcount() function in your PHP. Note that it returns a string, it doesn’t display it, so a typical usage would be something like:

Word Count: < ?php echo mtw_wordcount(); ?>

or more elegantly (for internationalization)

< ?php _e(’Word Count’,’mtw-wordcount’); ?>: < ?php echo mtw_wordcount(); ?>

I was careful to design this plugin “the right way” which includes my first foray into internationalization. The plugin includes translation files for French, Spanish and Russian. (The other languages I know.)

Click here to download the Word Count Plugin.


Tags:, .
评论数量(0) | Add Comments

There are No comments.

» You can leave a response or Trackback .

leave a reply