Step-by-Step Guide to Replace the ‘Read More’ Link in WordPress

Home » Snippets » Step-by-Step Guide to Replace the ‘Read More’ Link in WordPress

Created with:



Creator: WPTurbo Team

Customize with WPTurbo AI

Add Snippet To Project

New Project
Add To Existing Project

Struggling with the same old ‘Read more’ link on your WordPress site? Looking to customize it to better suit your web content style and branding? You’ve come to the right place. This article is a step-by-step guide on changing the default ‘Read more’ links in WordPress to anything you want. Whether you want to rename it, add unique styling or even hide it, we’ve got you covered.

					function wpturbo_modify_read_more_link() {
    return '<a class="more-link" href="' . get_permalink() . '">Your Custom Text Here</a>';
add_filter( 'the_content_more_link', 'wpturbo_modify_read_more_link' );

The function wpturbo_modify_read_more_link() is defined in the provided PHP code snippet. This function will be responsible for modifying the default "Read More" link text that WordPress automatically generates.

In the content of this function:

return '<a class="more-link" href="' . get_permalink() . '">Your Custom Text Here</a>';

We are creating an HTML a tag (hyperlink), with a class more-link. This class applies specific CSS styling for Read More links in most WordPress themes. You can replace this class with your own custom class if you want to apply different styling.

The href attribute of the link (where the link points to when clicked) is set to the permalink of the post. This is generated dynamically by calling the WordPress function get_permalink(). This function returns the URL of the current post, which is the standard behaviour for a "Read More" link – it should lead to the full post text.

Between the opening <a> and closing </a> tags, we have the text Your Custom Text Here. This is the text that will replace the default "Read More" text. Replace Your Custom Text Here with whatever text you want to use as your custom "Read More" text.

The final line of the snippet:

add_filter( 'the_content_more_link', 'wpturbo_modify_read_more_link' );

Here, we are hooking our new function into the WordPress ‘the_content_more_link’ filter. Filters in WordPress are used to modify or replace specific data at run-time – in this case, the default "Read More" text.

Whenever WordPress goes to create the "Read More" link, it will now use our function wpturbo_modify_read_more_link() instead of the default one. This will result in our custom text & styling being applied.

Register an account to save your snippets or go Pro to get more features.