Post Pic

Replacing the “read more” link on your WordPress blog

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!

19 Responses

Jul 06 2009 12:56

Hey, what doe’s it mean “you can’t change its text”? I can do it in the_content(‘READ MORE TEXT’)!

Jul 06 2009 17:57

I’d like to point out that the filter the_content_more_link was recently introduced in WordPress 2.8.

Jul 06 2009 18:30

Is there a way to have the read more always be there even if there isn’t any more text beyond what you see? I’ve got a site where the owner posts tons of pictures and often little text. In order to make the site more “friendly” I changed it so that only one picture shows up per post on the main page. In order for people to know that there is more pictures I setup the excerpt function, but the problem is that there isn’t always enough text to produce a read me. So is there a way to have it show the read more regardless?

Jul 06 2009 19:06

There’s a common trick – you can change MORE text easily if you just type your text after a space in a MORE tage

<–more Keep reading, folks –>

Jul 06 2009 19:21

@Elio: Didn’t know that! Thanks for notifying me!

Jul 06 2009 21:01

@seezer Great Tip!

Jul 06 2009 21:39

@Vanilla Man – This tutorial was taken a bit out of context. If you read the original article, you’ll see why this filter hook is important.

Jul 06 2009 21:46

Don’t forget you can style this text with the class .more-link

Jul 07 2009 12:23

Great tip and also thanks to seezer

Jul 07 2009 19:46

Very nice tip for older versions of WordPress. Thanks for sharing.

Jul 13 2009 06:45

Thanks.
Nice tip, re-tweet it now.

Jul 14 2009 11:43

Great tip. I guess it’s better than using plugins sometimes. I notice it makes the blog run slow.

Jul 20 2009 06:55

Hi,
Its surprisingly simple.
I try it on my WP blog.
Thanks.

Aug 25 2009 06:22

Um, where the heck do we modify this?? I’ve searched in function, index, single, everywhere. I want to change it from saying “Keep Reading” to something else…

Aug 25 2009 15:01

Neon: You don’t modify something unless it is already in your functions. What you want to do is copy this and then paste it into your functions.php file.

Aug 26 2009 06:50

@Nori Silverrage THANKS!

Oct 30 2009 05:32

how can I make the function work in current version wp.org on a page!! I am a novice!

Sep 01 2010 10:20

Thnx.
There is another method also
function more_text_image() {
$content = ‘Here goes your Text or HTML markup if you want to put up an image’;
return $content;
}
add_filter(‘more_text’, more_text_image);

Hope this will help

Trackbacks:

Leave a Comment

* Name, Email, Comment are Required