Article statistical info

n: smd_article_stats | v: 0.30 | f: /

Documentation for the Textpattern plugin smd_article_stats by Stef Dawson follows this short message from our sponsor ;-)

Plugin list buttonPlugin download buttonCompressed plugin download button


Put this tag in your article form to display info about the current article. Tags are ignored in the calculation. Note that it only displays the actual number of words entered in the article itself — if some of the content is derived from other forms, it will not be included.


  • item : list of items you want to count. The most common ones are body, excerpt or title to get the number of words in the relevant fields. You can supply any article field you like here (e.g. custom field: item="body, book precis, book author"). If you don’t specify anything then the fields used will be those selected from the prefs
  • label : label text to output before the requested count
  • labeltag : HTML tag without brackets to wrap around the label
  • wraptag : HTML tag without brackets to wrap around the output
  • class : CSS classname to apply to the wraptag (default: smd_article_stats)

Admin side

On the Write panel, the number of words in the document are displayed in a stats panel. It is updated in real time as words are entered in the given fields (defined in the plugin preferences). The article ID can also be displayed; hyperlinked to the article itself if it’s live or sticky. Set the Show article ID preference accordingly.

If you wish to move the panel to a different location on the Write panel, visit the Advanced prefs. You can then choose one of the following items from the list:

  • Above Status : (default location) above the Status box.
  • Above Title : above the Title box.
  • Above Textile : above the Textile Help twisty.
  • Below Textile : below the Textile Help twisty.
  • Below Excerpt : Immediately beneath the Excerpt.
  • Below Author : Beneath the author info (which is under the Excerpt). Note this position won’t appear for new articles until they are published.
  • None : disable the panel.

You may also customize which fields contribute to the count by altering the value in the Word count fields and DOM selectors box. List the fields using the syntax field -> DOM selector and separate each field with a comma. For example, to count words in the body, excerpt and custom 2 fields set the preference to:

Body -> #body, Excerpt -> #excerpt, custom_2 -> #custom-2

Author / credits

Written by Stef Dawson. Thanks to both zem and iblastoff for the original works that this plugin borrows as its foundation.


  • 24 Aug 2009 | 0.10 | Initial release
  • 07 Nov 2009 | 0.20 | Improved counting to ignore tags and added real-time admin-side counter (both thanks speeke)
  • 22 Feb 2010 | 0.21 | Prevented error message if step mangled
  • 06 Jun 2011 | 0.22 | Added paragraph wrapper to fieldset for consistency with TXP’s layout (thanks philwareham)
  • 14 Feb 2012 | 0.23 | Fixed excerpt_below auto-update mechanism ; added author_below position
  • 04 Apr 2012 | 0.24 | Expanded the available fields to anything in the article (thanks Teemu)
  • 21 Nov 2012 | 0.30 | For Txp 4.5.0+ ; added visible prefs ; made smd_article_stats tag take on defaults ; display of ID is optional

Source code

If you’d rather spend time with the bytes, you’ll need to step into the view source page.

Legacy software

If, for some inexplicable reason, you need a prior version of a plugin, it can probably be found on the plugin archive page.

Experimental software

If you’re feeling brave, or fancy going bareback, you can test out some of my beta code. It can be found on the plugin beta page.