Spare Pencil

Attachments

Donations

Advanced Excerpt

This plugin adds several improvements to WordPress’ default way of creating excerpts.

  1. It can keep HTML markup in the excerpt (and you get to choose which tags are included)
  2. It trims the excerpt to a given length using either character count or word count
  3. You can customise the excerpt length and the ellipsis character that will be used when trimming
  4. The excerpt length is real (ie. “words” and characters belonging to HTML tags are not counted)

In addition to keeping HTML markup in the excerpt, the plugin also corrects HTML that might have been broken due to the trimming process.

Installation

After you’ve downloaded and extracted the files:

  1. Upload the complete advanced-excerpt folder to the /wp-content/plugins/ directory
  2. Activate the plugin through the ‘Plugins’ menu in WordPress
  3. Go to ‘Excerpt’ under the ‘Options’ tab and configure the plugin

Frequently Asked Questions

Why do I need this plugin?

The default excerpt created by WordPress removes all HTML. If your theme uses the_excerpt() to view excerpts, they might look weird because of this (e.g. smilies are removed, lists are flattened, etc.) This plugin fixes that and also gives you more control over excerpts.

Does it work for WordPress version x.x.x?

I haven’t had the chance to test the plugin on many versions of WordPress. It has been tested on 2.2 through 2.5.1, but it might work on other versions, too. You can safely try it yourself, because the plugin is unlikely to break anything (it’s only an output filter). Please let me know if you succesfully tested it on another version of WordPress.

Can I manually call the filter in my WP templates, for example?

The plugin automatically hooks on the_excerpt() function and uses the parameters specified in the options panel. You can also call it manually and specify custom parameters. This can be useful for theme developers.
The following code is used to call the plugin’s filter function:

$advancedexcerpt->filter($text, $length, $use_words, $ellipsis, $allowed_tags)

Passing null to any of these parameters (except for the first) results in the default value being used instead. This way you can change the ellipsis without changing the length, for example.

License

This plugin is licensed under the GNU General Public License. Refer to the included COPYING file for more details.


Recent Comments

  • nathan
    on "Advanced Excerp…"
  • nathan
    on "Advanced Excerp…"
  • Bas
    on "Permission bug …"

Other Blogs