WordPress plugin: the excerpt re-reloaded
Published on November 29, 2008
UPDATED!
UPDATED AGAIN!
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).
Parameters
- 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)
Examples
<?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
Download
Click here to download it, then upload it as usual in wp-content/plugins folder. Suggestions are welcome.
the excerpt reloaded by Kaf Oseo works fine on my blog running WordPress 2.6.5.
Hi Jaypee, thanks for letting me know. I’ve only tested with WP 2.6.2, and it doesn’t work. I’ve seen a couple of people with my same problem, so I decided to publish this small fix. It is simpler to edit and it fix also the problem with the open tags in the excerpt.
No problem. I also used the excerpt reloaded plugin when I was using WordPress 2.6.2 and didn’t have any problems. Maybe your case and the ones who had problems with it was caused by a conflict with another plugin?
But nevertheless, its good to see another alternative plugin for displaying excerpts. Keep up the good work!
‘Advanced Excerpt” plugin is interesting too
First off, thanks for the update.
I’m using Kaf ‘s excerpt_reloaded for past 2+ years, and have not faced problems so far.
[...] you’re facing any problems with Kaf’s excerpt_reloaded plugin, Luca has updated the plugin to work with WordPress 2.6.x [...]
Thanks for your interest.
No, I wasn’t running other plugins, a standard version of WP 2.6 BUT with italian localization. I suspect it could depend on this, I’ll try to test it asap.
[...] That’s sweet ! Download the plugin here. [...]
[...] The excerpt re-reloaded [...]
[...] The excerpt re-reloaded [...]
[...] That’s course ! Download the plugin here. [...]
[...] The excerpt re-reloaded [...]
[...] That’s sweet ! Download the plugin here. [...]
[...] That’s course ! Download the plugin here. [...]
[...] Excerpt Re-reloaded [...]
[...] Excerpt Re-reloaded [...]
[...] Excerpt Re-reloaded [...]
[...] Excerpt Re-reloaded [...]
this plugin rocks, its actually one of the most usful i have found. there is just one feature i wish it had. the ability to remove strings or something similar. im using next-gen to place an image within a post (i would rather do it another way but this is the easiest for the noobies who want people to make them a website.
the except includes the call to the gallery
“[singlepic=14,320,240,,left]Sales are key to all businesses and how you gain sales will vary depending on your business and the market you work in. Many business do not have a structured sales …”
is there any way to remove that first call? without placing the image within the custom fields?
I double paul’s request.
It would be great to have the ability to filter elements in brackets like [galery=x], [audio:filename.mp3] [singlepic=...] etc.
Even without this, it’s really cool plugin. But with it, it would rock
Refering to my previous comment, maybe the could be done by replacing line 52
$text = strip_tags($post->post_content, $allowed_tags);
with
$text = preg_replace(‘/\[.*\]/’, ”, strip_tags($post->post_content, $allowed_tags));
(based on version 0.3 of your plugin)
Hi Karsten, thank you for your replies. I’ve been very busy and I’ve forgotten Paul’s request. I try to add this feature, starting from your tip. Stay in tune!
Ciao
Luca
Karsten, I’ve tested your fix and it works fine. I’ve included it in the new version (0.3.1) of the plugin, giving you the credits for it.
Works great, thank you
works like a charm
[...] – The Excerpt re-reloaded – This plugin is based off of the Excerpt Reloaded plugin by Kaf Oseo. The highlight of this plugin [...]
gran lavoro! proprio quello che cercavo!
complimenti!
i’ve uploaded the plugin and activated it but how do i use it? i don’t see it anywhere
thank you
Hi Ronnie, just call the_excerpt_rereloaded() within the loop.
See above for the examples.
i’m not sure what you mean Luca, could you please explain?… i’m very much a noob
do is work along withthe ‘more’ command when writting posts?
thanks for your help
No, you have to edit your theme pages (the ones where you want to show only the abstract), i.e. index.php. Where you find the_content(), replace it with the_excerpt_reloaded() and instead of the whole post content you will show the excerpt.
Check here for more information about the loop.
Aah, that should be of course. re_reloaded !! With the extra ‘re’.
Works great. Thanks Luca (using 2.7.1).
If you use ‘plain’ in the statement, the “Read more..” statement shows up nicely on the same text line. Good. Offcourse because it then is included in the section of the shorted message.
Nb. my site is still in test-fase. I am converting to WordPress. Learning every day.
Hi…! This rocks. You rock. Thank you for sharing and helping people out. I send you a virtual beer
[...] The Excerpt re-reloaded » Luca Biagini (url) This plugin does something more than the built-in excerpt function. It lets choose exceprt length, allowed html tags, the link text to full post and the html container of the excerpt (,, or plain text). [...]
Hi Luca,
I noticed that for the excerpt length, the words in an image title, under the images “Advanced links”, are included in the count; that is when the image is the first item in the post and I have “a” as allowed tag. The excerpt itself does not show the image, but still it is that number of words shorter than the other excerpts.
So, now I leave that “Advanced title” empty.
Still happy with it.
Hi Henk!
Thank you for letting me know, I havent noticed yet. I’ll take a look and try to fix it in the next version of my plugin.
Ciao
Luca
It works fine on WP 2.8.
Very good Plugin!
Thank you!
[...] porre rimedio a questo “problema” ho installato il plugin re-reloaded excerpt con la solita [...]
Hey there. This plugin is working fine on 2.8.4 and I have to say it’s absolutely great. I’d been looking for a proper one to replace a previous plugin because it didn’t list the “read more” link after a few updates. Thanks a lot for it!
I’d just like to say that the codes for emoticons don’t display properly even if the parameters are set to display all tags. Not really crucial, but it would be awesome if you could do a small fix? Only if you have the time, of course
Thanks again!
Hi Kersheys, I’don’t use emoticons and I haven’t noticed the problem. I’ve fixed it, check back soon for the new version. Thank you for posting. Ciao!
Luca
Awesome. Thank you! Updated and done~
I would indeed love to have paragraph breaks preserved as I desperately need it for my site! If it’s an easy fix certainly consider including it. Thanks!
Hello Luca,
Please make this plugin preserve the paragraph breaks. i really need it on my blog.
keep up the good work!
Thank you
WordPress newbie, using the Excerpt Rereloaded plugin (thank you) but my images are not showing up in home page summary. They are a single image placed first, ahead of the copy, if it matters. I have indicated “all” in the allowed tags code. If I change index.php code from “the_excerpt_rereloaded()” to “the_content()” they show up. Any thoughts?
TIA
@stanmc
By default images are not shown, you should specify it. See examples above.
That should work for you. Let me know otherwise.
@adrian & stuart
Unfortunately my plugin is based on excerpt_rss, so there’s no way to handle the “p” tag. I could try to manage it in the future, but that’s a pretty heavy modification I guess. Stay tuned!
Ciao
Luca
Hi Luca,
Thanks for the wonderful plugin. Just wonder if there is an luck for using it with double-byte language like Chinese.
In the meantime, I am falling back to the tag with my site.
Thanks in advance.
Hai folks,
i am a newbi to wp. still setting up the stuff. i already spend number of days fixing this excerpt thing by trying various excerpt plugins. non of them worked or had all the customizations i needed. finally i found your one was promissing and it allow exacly waht i wanted.
i just downloded the zip from wp plugin site. i open the the_excerpt_reloaded.php and put ‘all’ for $allowed_tags and included tag in the if section. [code] if ( $allowed_tags == 'all' ) $allowed_tags = ',,,,,,,,,
i just followed stanmc’s suggession.
that is replacing the “the_excerpt_rereloaded()” to “the_content()”. now its working. but still there are issues.
1. object tag not working even though i included in the if condition.
2. hanged image fit plugin also seems not working.
really really sorry to bump. the plugin now works really well on my wp 8.5. i only have one issue now. the image fit plugin does not work. coz it raps the resized image in ‘p’ tag. so until i find a fix for that, i just sticked to my old excerpt plugin (which does not have a facility to customized allowed tags).
pls try to fix this p tag issue.
@Patrick
I’m sorry, I’ve got really no experience with chinese, I don’t absolutely know how to help
@zamaan
Glad my plugin may help you, but unfortunately the object tag is not supported, and I don’t know the plugin you mentioned.
[...] of the default Argyll Communities theme by replacing the normal ‘the_excerpt’ tag by Luca Biagini’s ‘the_excerpt_rereloaded’. This allows us to control the appearance of the excerpted [...]
I upgraded my testsite to WP2.8.6 and using Advanced Title for images killed my read more link (it was visible but not linked). I solved that by letting out the “a” tag because the Advanced Title apparently created a starting “a” without closing it. So now I use
and that works good on WP 2.8.6
NB that is the first ‘no’ behind the raquo statement.
Nb2 the ‘plain’ still succeeds in having the –>> on the same line instead of a new line, good.
Sorry, can’t edit, so here goes again:
I upgraded my testsite to WP2.8.6 and using Advanced Title for images killed my read more link (it was visible but not linked). I solved that by letting out the because the Advanced Title apparently created a starting without closing it. So now I use:
“
(try to use backticks now fo showing code)
and that works good on WP 2.8.6
NB that is the first ‘no’ behind the raquo statement.
Nb2 the ‘plain’ still succeeds in having the –>> on the same line instead of a new line, good.
No luck:
php the_excerpt_rereloaded(’11′,’—»»’,'no’,'plain’,'no’);
Hi!
I’ve changed this line of the plugin:
$text = preg_replace(‘/\[.*\]/’, ”, strip_tags($post->post_excerpt, $allowed_tags));
Now instead of showing the content of the post, the plugin is showing the excerpt. The only problem is that when a post does not have an excerpt added manually, the plugin does not try to get the content.
I think that the perfect behaviour would be:
- check if there is excerpt, and if it is not blank, show the excerpt.
- if there is no excerpt, show the_content.
What do you think?
When I use [caption] in the beginning of a post (my post start with an image to the left of the text), the plugin won’t filter that tag away:
This is visible in the excerpt on my page, before the rest of the text:
[caption id="attachment_279" align="alignleft" width="139" caption="Glenn Svarts"][/caption]
I’m guessing that something is missing in this line to be able to hide the [caption]-tag/content?
$text = preg_replace(‘/\[.*\]/’, ”, strip_tags($post->post_content, $allowed_tags));
Hey Luca,
I have used this plugin on several sites but have occasionally been frustrated by what happens when only an image or only a video appears, returning an essentially empty excerpt.
So I wrote a companion function to get the output rather than automatically echo it. I called it get_the_excerpt_rereloaded() – it uses all of your same ideas but returns the output so I can test it and not display anything if it is empty.
I also noticed that essentially empty $output variables were actually a long string of spaces, so adding a trim statement emptied out any empty excerpts allowing me to test for whether it was empty.
I am just using it as a standalone plugin right now, but would love to send you the code if you want to check it out and maybe incorporate into the next version.
Thanks for the great plugin!
Marty
Hey! First of all.. thanks for this plugin!
So.. i need to make a Page excerpts (I do with “Page Excerpt” plugin) with the excerpt re-reloaded plugin..
somebody can help me?
Thanks a lot
Hey Thanks for this nice plugin. I have ‘all’ set for allowed tags, yet the plugin does not allow any images that happen to have a caption associated. Images without captions spit out just fine… but images with do not. Is it a problem with the plugin stripping out shortcodes? Can you change it?
Great plugin, saved my bacon. Only request for a feature would be to be able to change the words value to ‘more’ if necessary so that it could rely on the tag instead of just numeric values.
[...] Aside from writing multiple custom excerpt functions in functions.php, I found this plugin: The Excerpt Re-reloaded [...]
[...] fungerar upp till WordPress 2.9.2 och är väldigt smidig. Länk till författaren utav pluginet Lucabiagini.com Tags: custom, excerpt, [...]
[...] function to give the variable $t3 a value for the the_excerpt_rereloaded function. I use this plugin to display a custom ‘Read more’ text: [»] (You’ll need to install the plugin to [...]
[...] about a way to improve upon the default wordpress post excerpt by utilizing a plugin called the Excerpt Rereloaded. Luca Biagini wrote a great plugin that is all well and good for most people, but what about theme [...]
[...] The Excerpt re-reloaded [...]
Great plugin!
@MD (and anyone else interested) – in order to get this plugin to generate from a manual excerpt if provided, and the post body otherwise, replace this line:
$text = preg_replace(‘/\[.*\]/’, ”, strip_tags($post->post_content, $allowed_tags));
with this:
$orig = $post->post_excerpt;
if (empty($orig)) {
$orig = $post->post_content;
}
$text = preg_replace(‘/\[.*\]/’, ”, strip_tags($orig, $allowed_tags));
Hth. – Gus
[...] The Excerpt re-reloaded – http://www.lucabiagini.com/2008/11/wordpress-plugin-the-excerpt-re-reloaded/ [...]
Hi!
How to I prevent from specific code to appear in the excerpt? For instance, I use a Youtube Plugin that requires the following code to be added in my posts for the video to appear:
httpvh://www.youtube.com/watch?v=CODE
I would like this line to NOT appear in the excerpts. How?
See this screenshot from visual reference:
http://img238.imagevenue.com/img.php?image=27186_capture_123_179lo.jpg
Thanks for your help!
[...] The Excerpt re-reloaded: permite exibir um resumo de cada post e não seu texto completo; [...]
first of all, thanks for this great plugin.
I used the default settings of the plugin, but why it doesn’t diplay the image of my post?
Please help. Thanks
Great plugin.
I have the plugin installed but I don’t see where I go to customize it?
I have made some adjustments to the code to allow for breaks ( / ) to be allowed. I will try & post the code here:
function the_excerpt_rereloaded($words = 40, $link_text = 'Continue reading this entry »', $allowed_tags = '', $container = 'p', $smileys = 'no' )
{
global $post;
if ( $allowed_tags == 'all' ) $allowed_tags = ',,,,,,,,,,
//preserving tags in excerpt
$text = preg_replace('/\[.*\]/', '', strip_tags(apply_filters('the_content', $post->post_content), $allowed_tags));
//replacing p tags with br to allow read more link to be flush with text (optional)
$text = preg_replace("/]*>/", "", $text);
$text = str_replace("", "", $text);
$text = explode(' ', $text);
$tot = count($text);
for ( $i=0; $i
<?php if ( $i ...
<?php if ( $i < class="more">
<a href="" title="">
</>
Sorry – it stripped out quite a lot there… thought it might. I can send my adjusted file to anyone who wants it.
[...] The Excerpt re-reloaded: permite exibir um resumo de cada post e não seu texto completo; [...]
This is a great plugin. Everything is working perfectly and I’ve even built it into a few themes. Thanks for the code!
Does not work.
Sorry. My Mistake..
It does work just jump into your loop.php and add “_rereloaded” to the end of “the_excerpt”
I will test and report back.
Doesnt work. I cant see the widget in the widgets page. Im running wp 3.2.1
It does work indeed. No widget. Read the instructions.
[...] The Excerpt re-reloaded [...]
Plugin download link appears to be broken
@Casey Fixed!