Forked from studiopress/custom-readmore-excerpt.php
Last active
April 16, 2019 14:18
-
-
Save wpspeak/6653519 to your computer and use it in GitHub Desktop.
Customize [...] in WordPress excerpts
This file contains hidden or 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
<?php | |
//* Customize [...] in WordPress excerpts | |
add_filter( 'the_excerpt', 'sp_read_more_custom_excerpt' ); | |
function sp_read_more_custom_excerpt( $text ) { | |
if ( strpos( $text, '[…]') ) { | |
$excerpt = str_replace( '[…]', '<p><a class="more-link" href="' . get_permalink() . '">Read More →</a></p><br>', $text ); | |
} else { | |
$excerpt = $text . '<p><a class="more-link" href="' . get_permalink() . '">Read More →</a></p>'; | |
} | |
return $excerpt; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment