Skip to content

Instantly share code, notes, and snippets.

@wpspeak
Forked from studiopress/custom-readmore-excerpt.php
Last active April 16, 2019 14:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wpspeak/6653519 to your computer and use it in GitHub Desktop.
Save wpspeak/6653519 to your computer and use it in GitHub Desktop.
Customize [...] in WordPress excerpts
<?php
//* Customize [...] in WordPress excerpts
add_filter( 'the_excerpt', 'sp_read_more_custom_excerpt' );
function sp_read_more_custom_excerpt( $text ) {
if ( strpos( $text, '[&hellip;]') ) {
$excerpt = str_replace( '[&hellip;]', '<p><a class="more-link" href="' . get_permalink() . '">Read More &rarr;</a></p><br>', $text );
} else {
$excerpt = $text . '<p><a class="more-link" href="' . get_permalink() . '">Read More &rarr;</a></p>';
}
return $excerpt;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment