Last active
August 29, 2015 13:57
-
-
Save CoralSilver/9863570 to your computer and use it in GitHub Desktop.
Add "Read More" link to WordPress manual and automatic excerpts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 . ' <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