Snippet

Change the Excerpt Read More Text in WordPress

When WordPress creates an excerpt automatically, it cuts the post after 55 words and adds […] at the end. Those three dots in brackets don’t tell your readers much, and they are not even clickable. Most websites would rather show a proper “Read More” link that takes the reader to the full post. If you want the same on your website, you can replace the default ending using the following code. To change how many words the excerpt shows, have a look at our snippet to change the WordPress post excerpt length.

Where to place? functions.php of your child theme, or a code snippets plugin.

Usage

  • To give readers a clear, clickable way to continue to the full article from your blog page and archives.
  • To match the wording of the link with the tone of your website, such as “Continue reading” or “Read the full guide”.
  • To get more clicks from category and tag archive pages that only show excerpts.

Code


// Replace the [...] at the end of automatic excerpts with a Read More link
function wpt_excerpt_read_more( $more ) {
  if ( is_admin() ) {
    return $more;
  }
  return '&hellip; <a class="read-more" href="' . esc_url( get_permalink() ) . '">Read More</a>';
}
add_filter( 'excerpt_more', 'wpt_excerpt_read_more' );

This changes only the excerpts WordPress creates on its own. If you write a manual excerpt for a post, WordPress shows it exactly as you wrote it, without the link.

Explanation

  1. Just a comment to identify the code. You can keep it or remove it.
  2. Declaring our function wpt_excerpt_read_more and passing the $more argument, which holds the default […] ending.
  3. Checking whether we are inside the WordPress dashboard.
  4. If we are, we return the default ending as it is, so the admin screens are not affected.
  5. Closing the if statement.
  6. Returning our new ending: an ellipsis followed by a link to the current post. get_permalink() gets the post address and esc_url() makes it safe to print. Change Read More to any text you like.
  7. Closing the function.
  8. Adding our function to the excerpt_more filter, which WordPress runs every time it builds an automatic excerpt.