| WordPress
custom readmore

WordPress makes posssible to override many things, but it's not always easy to override language strings.

Sometimes language strings are in the WordPress core and you can override them using plugins.

However, sometimes language strings are included in the theme, and one common example is the "Read More" link for posts.

In this short tutorial, I'm going to show you how to customize the "Read More" link with a few lines of code.

Step #1. Create a child theme

If you haven't done so already, create a child theme so that you can safely add your customisations.

Step #2. Customize the "Read More" link

In the functions.php file for your child theme, add the following code:

function custom_readmore() {
return '<p><a class="custom-class" href="' . get_permalink() . '">Read More</a></p>';
}
add_filter( 'the_content_more_link', 'custom_readmore' );

In the above code, be sure to include get_permalink() to render the post permalink. Feel free to edit the surronding code, such as adding CSS classes and/or HTML tags.

Step #3. Test the end result

Go to your public site and check that your new link text is showing correctly.


About the author

Valentín creates beautiful designs from amongst the tequila plants of Jalisco, Mexico. You can see Valentín's design work all over this site and you can often find him helping members in support.