WordPress plugin: the excerpt re-reloaded
Published on November 29, 2008
The fantastic plugin The Excerpt Reloaded by Kaf Oseo, my trusted companion in dozens of WordPress installation, doesn’t work anymore on WP 2.6, so I have written an alternative version to finish the site I’m working on.
It’s a very small thing, not as complete as The excerpt reloaded, but, at least, it works, and it manages better than its inspirator the allowed tags, adding auto close to avoid pagination and validation errors.
It is based on the plain content of the post (like the content_rss in Kaf’s version) and like its predecessor, allowed tags cannot include <p> paragraphs, simply because I don’t need it on the site I’m currently developing, nor usually on any other. BTW, if somebody is interested, it can be easily fixed (or so I hope).
- words (integer): number of words to display before ending the excerpt. Default is 40.
- link_text (string): defines the text for the link to the full post. Default is “Keep reading this entry »”. Of course it is displayed only if the selected length is less than the full content. It is displayed in a <p> pararaph with its specific class (more), so it can be easily stylized.
- allowed_tags (string): defines which HTML tags to accept. Use the format ‘<img>’. For multiple tags, enter as single string: ‘<a><img>’. No tag allowed by default. NEW! Set to ‘all’ to accept all tags.
- NEW! container (string): defines the container of the excerpt: paragraph, span, div, or none. The container has a specific class=”more” to easily customize its layout through css. If you choose a “div” container, an additional “p” tag inside the div is automatically included. Default is “p”, for no container use “plain”.
- NEW! smileys (string): set ‘yes’ to convert text smileys to graphic images. Accepted values are ‘yes’ and ‘no’. Default is ‘no’. (I don’t like emoticons)
<?php the_excerpt_rereloaded(); ?> //display the excerpt with default settings. <?php the_excerpt_rereloaded('80','More','<strong><em>','div','yes'); ?> //display an excerpt of 80 words //the link to full post is simply "more" //allowed tags are strong and em //the link path is <div class="more"><p><a href="#etc">More</a></p></div> //text smileys are converted to graphic images <?php the_excerpt_rereloaded('80','More','all','plain','no'); ?> //display an excerpt of 80 words //the link to full post is simply "more" //all tags are accepted //the link path is included in the excerpt paragraph with no additional container //text smileys are NOT converted to graphic images
Click here to download it, then upload it as usual in wp-content/plugins folder. Suggestions are welcome.