Last active
December 17, 2017 07:24
-
-
Save version-control/65cfe268854da1ea77f43b7bb1fe6ef3 to your computer and use it in GitHub Desktop.
WP Theme Function For Excerpt Replace "Read More"
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
/** | |
* Filter the "read more" excerpt string link to the post. | |
* | |
* @param string $more "Read more" excerpt string. | |
* @return string (Maybe) modified "read more" excerpt string. | |
*/ | |
function wpdocs_excerpt_more( $more ) { | |
return sprintf( '<a class="read-more" href="%1$s">%2$s</a>', | |
get_permalink( get_the_ID() ), | |
__( 'Read More', 'textdomain' ) | |
); | |
} | |
add_filter( 'excerpt_more', 'wpdocs_excerpt_more' ); | |
// Replaces the excerpt "Read More" text by a link | |
function new_excerpt_more($more) { | |
global $post; | |
return '<a class="moretag" href="'. get_permalink($post->ID) . '">...</a>'; | |
} | |
add_filter('excerpt_more', 'new_excerpt_more'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment