Posts Tagged ‘Wordpress’



Changing Wordpress the_excerpt tag

Thursday, September 24th, 2009

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.