
Did you ever wondered why the the_excerpt() function always display [...] at the end of the post excerpt? To be honest, I don’t find this very beautiful. So, what about remove it? Just read on.

Did you ever wondered why the the_excerpt() function always display [...] at the end of the post excerpt? To be honest, I don’t find this very beautiful. So, what about remove it? Just read on.
To get rid of the [...] at the end of the post excerpt, simply paste the following function in the functions.php file from your theme:
function trim_excerpt($text) {
return rtrim($text,'[...]');
}
add_filter('get_the_excerpt', 'trim_excerpt');
And you're done! Goodbye [...]
By the way, I recently started a contest on Cats Who Code, where you can win premium WordPress themes. Sounds good to you? Click here to join.
22 Responses
Great Tip! Many themes have this nasty “feature”, fortunately mine don’t use this, but maybe I’ll need it sometime.
Very useful, I remember when I didn’t know this existed, very annoying those dots.
Thanks !
That’s it? I have tried to get rid of it before till I finally downloaded a plugin for the excerpts, wish I knew it was that easy before!
Thanks!!!
Thanks mate~!
Nice tip man, my theme is nasty one, it shows [...] after every post on home page. hope this will sort out the problem.
So simple but very useful, thankks.
Hi. I pasted the code but still see the [ ] tags.
Is there a particular place I should paste the code?
I just went to the end of the php file and pasted it.
Thanks
But how do I replace [...] with something else?
Nevermind.. Found out myself.
// custom excerpt ellipsis
function excerpt_ellipsis($text) {
return str_replace(‘[...]‘, ‘ Read more…‘, $text); }
add_filter(‘the_excerpt’, ‘excerpt_ellipsis’);
Nice tip, but it would be awesome if it’s working.
In my case, I’m using the_excerpt() to show posts and I have also written some texts in the “excerpt” textarea in the wp admin.
So, I would like to show the excerpt and just next a “read more” link, without using the_content(‘readmore’) but your custom excerpt function don’t even function.
Then I tried Blaze’s function, but its the same result.
May this could be the fact of my WP version? I’m actually using the 2.8.4 version.
Anyway, thanks for posting your tips!
@Ange Chierchia : all tips are tested, so yes, when a tip don’t work, it is 90% of the time due to WP version.
Ok, thanks.
I’ll to fix it, and post my code if I find what’s going wrong.
oops, I’ve forgot the “try” lol!
I’ll try to fix it
My code works, however some of the code gets stripped out here in the comments. Here it is again:
// custom excerpt ellipsis
function excerpt_ellipsis($text) {
return str_replace(‘[...]‘,’Read more..‘, $text);
}
add_filter(‘the_excerpt’, ‘excerpt_ellipsis’);
ARGH! Anyone know of a way to post code inside comments without the tags getting stripped out?
Thanks for the awesome tip Jean.
I really would love that code that Blaze is trying to
share with us. i really want to have a link pointing
to the rest of the post. Some people don’t know to
click on the title.
You just need to change the single quotation marks (‘) in Blaze’s code once you copied-pasted into your code. Just change them back to the code standard and the code works fine. Cheers Blaze!
Trackbacks: