the_content_more_link

Home » Hooks » the_content_more_link

The the_content_more_link hook is a WordPress filter hook that allows developers to modify or replace the "Read More" link that is automatically added to excerpts or content that has been truncated using the <!--more--> tag.

By default, the "Read More" link generated by WordPress is a simple text link with the anchor tag <a> that directs users to the full post page. However, using the the_content_more_link hook, developers can customize this link to match the design and functionality of their website.

This hook is especially useful for themes or plugins that want to provide a more engaging or visually appealing "Read More" link. For instance, you may want to replace the default link with a button, add an icon before the text, or even add a tooltip.

To use the the_content_more_link hook, you would need to add a callback function and specify it in your theme’s functions.php file or in a custom plugin. Here is an example usage code:

function custom_read_more_link($link) {
    // Modify the "Read More" link
    $link = '<a class="button" href="' . get_permalink() . '">Continue Reading</a>';
    return $link;
}
add_filter('the_content_more_link', 'custom_read_more_link');

In the example above, we have defined a callback function custom_read_more_link that modifies the link to be a button with the class "button" and the text "Continue Reading". The modified link is then returned and replaces the default "Read More" link.

By using the the_content_more_link hook, you have the flexibility to customize the appearance and behavior of the "Read More" link in your WordPress website.

Learn More on WordPress.org

WordPress snippets using the the_content_more_link hook

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