How to Display a Read More link in WordPress Excerpts

Posted on August 2nd, 2010 by in Tutorials | 12 Comments  
How to Display a Read More link in WordPress Excerpts
This post is supported by Managed Hosting from Hosting.com

To prevent duplicate content, improve site load time, and for better SEO many bloggers have started to use post excerpts. Excerpts are mini-descriptions of the posts shown on the main blog page, category pages, and archive pages. You can see a live example by visiting any of our categories. But if you notice, our read more button is added on a separate line from the excerpt text. In this article, we will show you how to automatically add a read more link in WordPress Excerpts.

First open your functions.php file, and paste the following code inside the php tags:

 // Changing excerpt more
    function new_excerpt_more($more) {
    global $post;
    return '… <a href="'. get_permalink($post->ID) . '">' . 'Read More &raquo;' . '</a>';
    }
    add_filter('excerpt_more', 'new_excerpt_more');

In this function, you are telling WordPress to remove the default more which looks like this: [...], and replace it with a link. This short and simple tutorial was requested via our suggestion form. You can suggest article ideas as well by using our suggestion form or our twitter @wpbeginner.

About

Editorial Staff at WPBeginner mainly Syed and David.

Post comment as twitter logo facebook logo
Sort: Newest | Oldest

Thanks, was exactly what I was looking for

Where to post this code exactly.....i dont know....actually i m new at wp...can you tell me...

If post contain Image than can it appear at homepage or not?

Mia 5 pts

Thanks for the Post! But I have a small problem...

It worked, but I get a question mark symbol before the "read more"-link in every excerpt. How do I remove that?

wpbeginner 50 pts moderator

Mia The symbol is coming there because you pasted this code into a code-editor like Dreamweaver which didn't understand the ... symbol. Replace the .... with &amp;hellip; and it will fix itself.

Mia 5 pts

wpbeginner That worked! Thanks for the answer!

wpbeginner 50 pts moderator

Ibadullah the code should work because we have it running on quite a few sites.

I just finished putting your code in today on a site and it does the trick perfectly Thanks

Hi. I used your code for custom loop for custom page in wordpress and it worked fine, the only thing is that it shows the whole post, "more" link doesn't work for some reason. I tried the code above and same thing. Maybe you have any suggestions? Thanks for your articles, they are very helpful. If you need more info from me let me know.

I think it's because the article only includes one part of the solution, the piece that goes into the functions.php. The other piece that is needed is here on the wordpress site, read this :http://codex.wordpress.org/Customizing_the_Read_Mo....

Hope that helps.

P.S. For me the solution doesn't work. After I load the 6 lines of code indicated above in this wpbeginner beginner article, my Wordpress editor goes white every time I click update file...bummer. Any other ways you guys know of?

Tweets about us: