Customize the Read More Links in 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:

{codecitation php}function custom_readmore() {
return ‘<p><a class=”custom-class” href=”‘ . get_permalink() . ‘”>Read More</a></p>’;
}
add_filter( ‘the_content_more_link’, ‘custom_readmore’ );{/codecitation}

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.

Author

  • Valentin Garcia

    Valentin discovered Joomla in 2010, and since then he has considered it as the best CMS. Valentin has been coding extensions and templates for Joomla for many years and truly enjoys helping people build their own websites with Open Source tools. He lives in San Julián, Jalisco, México.

    View all posts
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x