Skip to content

Instantly share code, notes, and snippets.

@CoralSilver
Last active August 29, 2015 13:57
Show Gist options
  • Save CoralSilver/9863570 to your computer and use it in GitHub Desktop.
Save CoralSilver/9863570 to your computer and use it in GitHub Desktop.
Add "Read More" link to WordPress manual and automatic excerpts
function custom_excerpt($text) { // custom 'read more' link
if (strpos($text, '[...]')) {
$excerpt = strip_tags(str_replace('[...]', '... <a href="'.get_permalink().'">read more...</a>', $text), "<a>");
} else {
$excerpt = '<p>' . $text . '&nbsp;&nbsp;<a href="'.get_permalink().'">read more...</a></p>';
}
return $excerpt;
}
add_filter('the_excerpt', 'custom_excerpt');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment