Add Read More Link to Post Excerpt

If you want to add a link to the full post at the end of the post excerpt, you can do it like this. Add the following code to your functions.php file:

function savvy_excerpt_link_post($text) {
    return str_replace( '[...]', '<a href="'. get_permalink( get_the_ID() ) . '" title="' . esc_attr( get_the_title( get_the_ID() ) ) . '">' . '[&hellip;]' . '</a>', $text );
}
add_filter('the_excerpt', 'savvy_excerpt_link_post');

This uses the excerpt_more filter. Learn more in WordPress Hooks Explained.

Discussion
[  0 Comments  ]

Leave a Comment

To add code, use the buttons below. For instance, click the PHP button to insert PHP code within the shortcode. If you notice any typos, please let us know!