Last active
March 1, 2021 16:58
-
-
Save cccamuseme/fcf730b7c21d669139c9df54fdfe11a3 to your computer and use it in GitHub Desktop.
Custom WordPress blog excerpt and read more link
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
<?php | |
// custom excerpt length | |
function my_custom_excerpt_length( $length ) { | |
return 40; | |
} | |
add_filter( 'excerpt_length', 'my_custom_excerpt_length', 999 ); | |
// add more link to excerpt | |
function my_custom_excerpt_more($more) { | |
global $post; | |
return '... ' . '<a class="more-link" href="' . get_permalink() . '">Read More</a>'; | |
} | |
add_filter('excerpt_more', 'my_custom_excerpt_more'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment