Add “Read More” link to the end of an excerpt

An excerpt is also known as a short summary and is usually shown on blog pages. Instead of displaying the entire post on your homepage, excerpts allow you to show only a part of it which can make the user interested in the article.

After users see the title, image, and excerpt of your post, you need to inform them that they can read more about the topic by following the link to your article. If you ask us, a featured image should always lead to the main article, but you should also allow your readers to follow the “Read More” link or a button.

Add "Read More" link to the end of an excerpt

If your theme doesn’t have the feature already included, you should create one for yourself. In this article, we’re about to show you how to quickly add “Read More” link at the end of each excerpt:

    >
  1. Open functions.php
  2. Copy and paste the code:
  3. function excerpt_readmore($more) {
    return '... <a href="'. get_permalink($post->ID) . '" class="readmore">' . 'Read More' . '</a>';
    }
    
    add_filter('excerpt_more', 'excerpt_readmore');
  4. Change the text if you want to
  5. Add a different class if you want to style the link differently
  6. Save changes

That’s actually all there is. After you’ve have saved the changes, each and every excerpt on your WordPress powered website will now get a “Read More” text (or whatever did you write in the code above) with a link to the original post attached to it automatically.

You can check out the result by opening your homepage, blogroll or wherever you’re displaying post’s excerpts.

Now that you have modified the way your excerpts are being displayed, you may be interested in changing the length of your excerpts.

If you would like to have more control over excerpts or you don’t like messing around with the custom functions, you should take a look at Advanced Excerpt plugin.

Want more tutorials like this one? Check out our WordPress tutorials library, see the guides, and learn more about blogging in general.

START YOUR OWN BLOG

This guide is an introduction to mastering the art of blogging. It provides easy to follow steps to start, maintain, and grow your blog.

Read the guide

Leave a Reply

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