Site icon Graph Paper Press

Tip: How to change the default WordPress excerpt

Ever get tired of those nasty […] ellipses that appear beneath your blog excerpts? I do. In this tutorial, I am going to show you how to change WordPress’ default excerpt display without changing core WordPress files.

Open up functions.php and add this code to the very bottom of the file:

<?php function gpp_excerpt($text) { return str_replace('[...]', '<br /><a href="'.get_permalink().'">Read More &rarr;</a>', $text); } add_filter('the_excerpt', 'gpp_excerpt'); ?>

The above code “filters” WordPress’ default the_excerpt function and replaces it with our own gpp_excerpt function. We have just written a very simple plugin for WordPress.

If, however, you are writing your own excerpts and want to add a Read More permalink, replace:

<?php the_excerpt(); ?>

with this:

<?php the_excerpt(); ?><span class="read_more"><a href="<?php the_permalink(); ?>">[ Read More &rarr; ]</a></span>

If you found this tutorial useful, consider subscribing to Graph Paper Press. You will get access to our support forum, where additional tutorials similar to this one are available to our subscribers.

Exit mobile version