Append permalinks to WordPress posts excerpts

Excerpts are short extracts of posts. You may define manually your extracts adding them in the excerpt field. If you forget to set an excerpt to your post WordPress grabs it automatically from the first lines of each post.

Normally WordPress uses a function called the_excerpt(). As mentioned above, this function displays a short extract of your post followed by an ellipsis (…). The question is What if you want to replace the ellipsis with a read more link? It would make more sense for your excerpts. Wouldn’t it?

The following snippet comes in handy to customize your excerpts by appending a permalink to them. You can change the read more text as you wish.

PHP
//Append a permalink after post excerpt
function wph_append_post_permalink($content) {
	return str_replace('[...]',
		'<a class="read-more" href="'. get_permalink() .'">Read More</a>',
		$content
	);
}
add_filter('the_excerpt', 'wph_append_post_permalink');