WordPress the_excerpt Plugin

2 minute read

Recently, I was looking for a solution for extracting post text by defining the length of the string. WordPress offers two useful functions:

  • the_content(): returns the full content of a post

  • the_excerpt(): returns a fixed extracted text from a post, but no parameter option is provided.

The idea is to write a better function that has a few optional parameters to extract text from an entry. I found an “old” plugin has done all the nice jobs for the developes. It’s old because it’s not updated since March 2005. However, the plugin still works with the latest WordPress release.

If you ever need such function, take a look “the excerpt reloaded”. Below is quoted documentation from author’s website.


excerpt_length (integer) Number of words to display before ending the excerpt. Default is 120. allowedtags (string) Defines which HTML tags to retain in excerpt. Use the format '<img>'. For multiple tags, enter as single string: '<a><img>'. Default is '<a>'. filter_type (string) Defines how WordPress should filter/format an excerpt’s content. Options are based on content/excerpt tags: 'content', 'content_rss', 'excerpt', 'excerpt_rss'. Set to 'none' to display raw content. Default is 'excerpt'. use_more_link (boolean) Should the “more” link be displayed (TRUE) or not (FALSE). If set to false, function displays ellipsis (…) if content more than that displayed; neither link nor ellipsis displays if output is less than excerpt_length; Defaults to TRUE. more_link_text (string) If use_more_link is set to TRUE, set this to define what text to use for the link. Default is '(more...)‘. force_more_link (boolean) Display more link (TRUE) or not (FALSE), even when excerpt is less then excerpt_length. Defaults to FALSE. fakeit (integer) Use content as excerpt (1) or not (0) if excerpt is empty. Set to 2 to force content as excerpt under all conditions. Defaults to 1. fix_tags (boolean) “Repair” HTML tag elements (TRUE) or don’t (FALSE). This is implemented to deal with improperly closed tags which may be caused by excerpt_length. If fix_tags is set to FALSE, the plugin will not attempt XHTML validation and repair on improperly closed tags (due to excerpt_length breaking them in mid-element). Defaults to TRUE.

Leave a comment