Home / Blog / Code Snippets
,

Display a Read More link in WordPress Excerpts

First published 22 Jul 2017. Tested again in November 2026 on WordPress 7.1.4 and PHP 8.4.

Nowadays, WordPress Post Excerpt is used in almost every blog to display Post summary on Archive pages and Search result page. This post will show you how to add [Read more…] in WordPress post excerpt with a link to post single page.

Add the code below to your theme’s functions.php file.

// Add "Read More" after hand-written excerpts.
function add_read_more_to_excerpt( $excerpt ) {
    if ( ! is_admin() && has_excerpt() ) {
        $excerpt .= ' <p><a class="read-more" href="' . esc_url( get_permalink() ) . '">Read More »</a></p>';
    }
    return $excerpt;
}
add_filter( 'the_excerpt', 'add_read_more_to_excerpt' );

// Replace the default [...] in automatic excerpts with a "Read More" link.
function custom_excerpt_more( $more ) {
    if ( is_admin() ) {
        return $more;
    }
    return '... <a class="read-more" href="' . esc_url( get_permalink() ) . '">Read More »</a>';
}
add_filter( 'excerpt_more', 'custom_excerpt_more' );

The first filter adds the link after excerpts you write by hand. The second replaces the default […] on automatic excerpts. An earlier version of this snippet added the link twice on automatic excerpts; this one adds it once.

View or fork this snippet on GitHub Gist.

Need this done on a live site? Exivon Tech takes on projects and audits, led by me.

Dhiren Patel

Principal Full-Stack Engineer · Founder, Exivon Tech

I’ve built and run enterprise web platforms and e-commerce for 13 years, and I built ShieldScope, a free WordPress security scanner.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.