Replacing the “read more” link on your WordPress blog

July 6, 2009 at 11:04 am

The “more” tag is indeed very useful in WordPress because it allow you to define a portion of post to be displayed on your blog homepage. Though, the problem with the “more” link is that you can’t change its text. Excepted if yoou apply this recipe.

Nothing hard here. All you have to do is to define the desired text for your more link on line 3, and then paste the code snippet on your functions.php file.

<?php

$custom_more = "Continue reading this post";
add_filter( 'the_content_more_link', 'my_more_link', 10, 2 );

function my_more_link( $more_link, $more_link_text ) {
	return str_replace( $more_link_text, $custom_more, $more_link );
}
?>

That’s all. Using the power of hooks, you have defined a new text for the more link.

Credits goes to Justin Tadlock for this great recipe!

Tags: