The code in this tutorial enables you to do 2 things :
- You can control the length of the excerpt
- Add a custom read more link to the end of your excerpts
Genesis Users Note : This code assumes you’ve set the Genesis > Theme Settings > Content Archive > Display > settings to show Entry Excerpts and not Entry Content
Usage In Functions File
Add the following PHP code to the end of your child themes functions file.
This code uses get_the_excerpt filter
add_filter( 'get_the_excerpt', 'link_excerpt_more' );
function link_excerpt_more( $output ) {
$more = sprintf( ' <a href="%s" class="more-link" rel="bookmark">' . __( 'Read More' ) . '</a>', esc_url( get_permalink() ) );
return $output . $more;
}
You can also use the_excerpt filter like this :
add_filter( 'the_excerpt', 'link_excerpt_more' );
function link_excerpt_more( $output ) {
$more = sprintf( ' <a href="%s" class="more-link" rel="bookmark">' . __( 'Read More' ) . '</a>', esc_url( get_permalink() ) );
return $output . $more;
}
Customize Code
- Swap out the 15 in the 1st code snippet to control the length of the excerpts.
- You can also modify the Read More text in the 2nd code snippet.
Leave a Reply
You must be logged in to post a comment.