Skip to content

Instantly share code, notes, and snippets.

@cccamuseme
Last active March 1, 2021 16:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cccamuseme/fcf730b7c21d669139c9df54fdfe11a3 to your computer and use it in GitHub Desktop.
Save cccamuseme/fcf730b7c21d669139c9df54fdfe11a3 to your computer and use it in GitHub Desktop.
Custom WordPress blog excerpt and read more link
<?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