Create custom “Read more” links on your WordPress blog

June 19, 2009 at 8:36 am

The “more” link is indeed a great WordPress capability, which allow you to choose the part of the post to be displayed on the homepage. Then, a “Read more” link is displayed. But how can you change the text of this link? Just read on.

To achieve this recipe, the first step is to edit your posts and create custom fields. Give them custom_more as a key, and the text to display as a value.

Once done, edit your index.php file (As well as category.php, search.php, etc) and find a line similar to this:

the_content("

Simply replace it with this code:

<?php $custommore = get_post_meta($post->ID, 'custom_more', true); ?> 
<?php if (!$custommore) { $custommore = 'Read More &raquo;'; } ?> 
<?php the_content($custommore); ?>

That’s all. Now, if you create a custom field named custom_more, its value will be displayed instead of the classic “Read more” link.

Thanks to Chris Cagle for this very usefull trick!