X

Add “Read More” Permalink to the End of the_excerpt

Snippets by IsItWP

Do you want to add “Read More” permalink to the end of the the_excerpt? While there’s probably a plugin for this, we have created a quick code snippet that you can use to add “Read More” permalink to the end of the the_excerpt in WordPress.

Instructions:

All you have to do is add this code to your theme’s functions.php file or in a site-specific plugin:

function excerpt_readmore($more) {
	return '... <a href="'. get_permalink($post->ID) . '" class="readmore">' . 'Read More' . '</a>';
}
add_filter('excerpt_more', 'excerpt_readmore');

Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly add code snippets in WordPress, so you don’t accidentally break your site.

If you liked this code snippet, please consider checking out our other articles on the site like: 50+ best responsive WordPress themes to create a mobile-ready site and how to create a job application form in WordPress.

Comments  Leave a Reply

  1. brigitte pixner May 27, 2019 at 12:47 pm

    using wp theme twenty nineteen, your excerpt tweak throws the following error:
    Undefined variable: post /functions.php on line 2 Notice: Trying to get property of non-object in /functions.php on line 2

    “line 2” refers to the code in line 2 of your code example above.

  2. for function.php
    ………………………………
    function custom_read_more() {
    return ‘ Continue Reading »‘;
    }
    function excerpt($limit) {
    return wp_trim_words(get_the_excerpt(), $limit, custom_read_more());
    }
    ………………………..
    for index.php
    ………………………….

  3. shirish nagansurkar December 22, 2016 at 8:42 pm

    I am using Deep Sea theme, trick is not working for me, kindly suggest something to fix it.

    1. Without seeing your theme I would have no idea, I would guess that they don’t use the_excerpt() in the theme as expected so it does not work. This snippet simply just replaces […..] with my custom read more.

  4. 1. At the end of my post , a button named “permalink” is showing but i want to change it to “read more”.
    2. While clicking on this button , my Featured image is not showing up , all i can see is my Post without its Featured image.
    Suggest something….

  5. ah perfect, thank you so much!

  6. Is there a way to add the post title to the read more section?

  7. Didn’t work for me =(

    1. Do you use the “the_excerpt” function within your template?

  8. Append ‘Read More’ to the end of the_excerpt | WerdsWords July 6, 2011 at 12:40 pm

    […] WPSnipp.com Share this […]

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!
[60% OFF Today!]
[60% OFF Today!]
[10% OFF Today!]
[10% OFF Today!]
[50% OFF Today!]
[50% OFF Today!]