Last active
April 16, 2019 14:23
-
-
Save studiopress/6091191 to your computer and use it in GitHub Desktop.
Add Read More Link for Automatic and Custom 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 | |
//* Do NOT include the opening php tag shown above. Copy the code shown below. | |
//* Add Read More Link to Automatic and Custom Excerpts Site-wide | |
add_filter( 'the_excerpt', 'sp_read_more_custom_excerpt' ); | |
function sp_read_more_custom_excerpt( $text ) { | |
if ( strpos( $text, '[…]') ) { | |
$excerpt = str_replace( '[…]', '<a class="more-link" href="' . get_permalink() . '">[Read More…]…</a>', $text ); | |
} else { | |
$excerpt = $text . '<a class="more-link" href="' . get_permalink() . '">[Read More…]</a>'; | |
} | |
return $excerpt; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment