Post Pic

How to: Remove the [...] from the excerpt

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

Mar 13 2009 20:02

Great Tip! Many themes have this nasty “feature”, fortunately mine don’t use this, but maybe I’ll need it sometime.

Mar 16 2009 21:30

Very useful, I remember when I didn’t know this existed, very annoying those dots.

Mar 22 2009 20:09

Thanks !

Mar 23 2009 05:54

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!!!

Mar 23 2009 14:33

Thanks mate~!

Mar 31 2009 14:17

Nice tip man, my theme is nasty one, it shows [...] after every post on home page. hope this will sort out the problem.

Apr 10 2009 13:47

So simple but very useful, thankks.

Jun 18 2009 05:50

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

Jul 23 2009 13:15

But how do I replace [...] with something else?

Jul 23 2009 14:10

Nevermind.. Found out myself.

// custom excerpt ellipsis
function excerpt_ellipsis($text) {
return str_replace(‘[...]‘, ‘ Read more…‘, $text); }
add_filter(‘the_excerpt’, ‘excerpt_ellipsis’);

Oct 15 2009 01:27

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!

Oct 15 2009 07:38

@Ange Chierchia : all tips are tested, so yes, when a tip don’t work, it is 90% of the time due to WP version.

Oct 15 2009 15:44

Ok, thanks.
I’ll to fix it, and post my code if I find what’s going wrong.

Oct 15 2009 15:45

oops, I’ve forgot the “try” lol!
I’ll try to fix it

Oct 15 2009 17:15

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’);

Oct 15 2009 17:16

ARGH! Anyone know of a way to post code inside comments without the tags getting stripped out?

Oct 23 2009 05:30

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.

Nov 06 2009 12:18

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:

Leave a Comment

* Name, Email, Comment are Required