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!

7 Responses

Jul 17 2011 12:28

Do you know how can i edit the text “Read More” to something else like “click to read more” or “click here to read more”?

I am using WordPress!

Can anybody help?

Thanks.

Nov 05 2011 17:15

Find this code in your index.php file:

and change it to this:

or

Nov 05 2011 17:29

opss code skipped …

anyways just find code in your index.php file then find content and write read more as (‘read more’)

Apr 03 2012 16:18

I pasted the code into my functions.php.

However – there are no words on the “more” button.

I have tried to edit the index file as well – no change.

Can you help?

Be glad to paste any code that you need to see.

Nov 05 2012 00:02

Do you also know how to change the ‘read more’ into a picture?

Dec 09 2012 12:23

Hello Khalid, can you please advice, how to justify the text alignment for the posts which are shown on the homepage.

Apr 24 2013 06:16

Sorry, you do need to include the first two lines to get it to work, just changed the $custom_more to ‘Read more’.

Trackbacks:

Leave a Comment

* Name, Email, Comment are Required

WP Theme of the week

Punk rock anyone?