This plugin hasn’t been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.

Better Excerpt

Description

By default, the WordPress excerpt is fixed at 55 words, wrapped in <p> tags and with […] as an unlinked ellipsis at the end. This plugin allows you to specify the length of the excerpt you want, text or HTML before the excerpt, text or HTML after the excerpt, and whether you want to automatically append a link to the full post.

Example uses:

  • set the excerpt at a length that works with your magazine-style theme
  • automatically wrap every excerpt in div tags
  • automatically add a “read more” link after your excerpt, linking to the full post
  • get rid of that super-annoying […] thing!

Installation

  1. Upload betterexcerpt.php to the /wp-content/plugins/ directory
  2. Activate the plugin through the ‘Plugins’ menu in WordPress
  3. Set your own preferences in Settings > Better Excerpt

FAQ

Does it remove HTML tags?

Yes, it does.

Can’t you make it leave HTML tags in?

If you want to leave HTML in, then the “more” tag is your friend. the_excerpt is meant to remove HTML.

How can I have excerpts of different lengths?

You can manually call the function like this:
<?php echo better_excerpt($length, $ellipsis, $before_text, $after_text, $link_to_post, $link_text); ?>
for example
<?php echo better_excerpt(500, ‘…’, ‘

‘, ‘

‘ ‘1’, ‘read more’); ?>
obviously replacing the variables with your own values. The value of link_to_post should be ‘yes’ or ‘no’. All variables need to have values, so if you don’t want any – e.g. – code before or after the extract, you need empty inverted commas ”

Does it leave half-words at the end of my excerpt?

No, it doesn’t: half-words are trimmed back to the end of the previous word.

I set length to 55 but it’s only giving me about 10 words

Length is set in characters – that is, letters, numbers, spaces and bits of punctuation. We do it like this because some people use lots of long words, and some people don’t, so a ten word excerpt for some would be the same length as a twenty word excerpt for others. As a general rule of thumb, assume 5 letters in the average English word.

I installed it but now I get a fatal error for strrpos…

This plugin requires PHP5. Most likely, you’re still running PHP4. It’s time to upgrade.

Contributors & Developers

“Better Excerpt” is open source software. The following people have contributed to this plugin.

Contributors

Translate “Better Excerpt” into your language.

Interested in development?

Browse the code, check out the SVN repository, or subscribe to the development log by RSS.

Changelog

0.2.1

  • correted error in documentation for manual plugin – oops!

0.2

  • added manual function to allow excerpts of varying lengths
  • tidied up the read me file!

0.1

  • original release