Changing Wordpress the_excerpt tag

I love Wordpress and everything that the tool lets you do. A friend/client hit us up today asking how he could get rid of the default “[...]” text at the end of the Wordpress the_excerpt tag. I figured this may be a pretty common question, so I decided to share the solution here. I know I am not the only one to figure this out, but here is what I did:

  • Login to the Wordpress backend (with admin rights) and click on the arrow next to the appearance tab
  • Click on the “editor” link
  • In the right column find the Theme Functions (functions.php) file and click on it to edit
  • Add in the following function right before the closing “?>” php tag. We utilized the add_filter tag to replace the “[...]” with “Read More ยป”. You’ll notice we also added in the permalink so you can click on the link to actually read more.
    function change_excerpt($excerpt)
    {
    return str_replace('[...]', '<br /><a href="'.get_permalink().'">Read More &raquo</a>', $excerpt);
    }
    add_filter('the_excerpt', 'change_excerpt');
  • Finally, go do something nice for yourself because you have now globally changed the_excerpt tag for this template

Hope this helps someone.

Tags: , , , , ,

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

One Response to “Changing Wordpress the_excerpt tag”

  1. Laurie says:

    I stumbled on you through Google. This is exactly what I've been looking for for months. It's been very helpful. Thanks! :)

Leave a Reply

Contact Us
Visit the Blog
Twiiter Feed