Replace … with “Read More” link or button

⚠️ Code snippets might not be compatible with the latest version of your theme. Always use a child theme to customize your theme, and test your code on a staging website before migrating to production.

In the alternate thumbnails layout, the default display shows the excerpt with a […] at the end. The thumbnail and the title are linked to the post. If you want to add a “Read More” link or a “Read More” button, here is how your do it.

To replace the […] with a [Read More] link, add this to your child theme’s functions.php

function new_excerpt_more($more) {
    global $post;
    return ' <a class="moretag" href="'. get_permalink($post->ID) . '">[Read More]</a>'; //Change to suit your needs
}

add_filter( 'excerpt_more', 'new_excerpt_more' );

 

To replace the […] with a Read More button, add this to your child theme’s functions.php

function new_excerpt_more($more) {
    global $post;
    return ' <a class="moretag btn btn-primary" href="'. get_permalink($post->ID) . '">Read More »</a>'; //Change to suit your needs
}

add_filter( 'excerpt_more', 'new_excerpt_more' );

 

Leave a comment

Your email address will not be published. Required fields are marked *

8 thoughts on “Replace … with “Read More” link or button”