‘Read-more’ on all Excerpts in WordPress

Occasionally, the excerpt does not show a read-more at the end of the text. This is obviously the case, if the text content of the post is shorter than the set excerpt length.

Normally this is no problem – however, if your post contains images and/or important formatting, you would like to point the reader to the full post.

The above also assumes that you have customized your theme, to show a link to the post at the end of the excerpt – refer to the Codex chapter ‘Make the read-more link to the post‘.

A way to remedy the situation, is to edit functions.php of the theme, and to find the related code, such as:

function new_excerpt_more($more) {        global $post; 	return '<a href="'. get_permalink($post->ID) . '">' . 'Read the Rest...' . '</a>'; } add_filter('excerpt_more', 'new_excerpt_more');

Remove that, and add a new filter function in its place; something like:

function excerpt_read_more_link($output) {
 global $post;
 return $output . '<a href="'. get_permalink($post->ID) . '">Read All ...</a>';
}
add_filter('the_excerpt', 'excerpt_read_more_link');

And now you have a ‘read-more’ link at the end of each excerpt, linked to the full post.

12 Replies to “‘Read-more’ on all Excerpts in WordPress”

  1. Thanks for this code but one question. How do I remove the […] that is appearing before the “read more” link. I’d rather not have both […] and read more in the excerpt.

    Thanks!

  2. Hi alchymyth,

    your solution “‘Read More’ to appear inline at the end of the excerpt” … works fine … Thanks …
    Do you know, whats the code to make “Read All …” translatable? I need the solution for a multilingual page …
    Thanks for your help in advance

    Greats from Berlin / Germany
    Hardy

    1. Hi Michael,

      danke für den Hinweis … dein Code erzeugte wieder einen neuen Absatz …
      This code did the trick …
      return substr($output,0,-5).'<a href="'. get_permalink($post->ID) . '">'. __(' ... <strong>Continue reading <span class="meta-nav">&rarr;</span></strong>','twentyeleven') . '</a>';

      Danke
      Eberhard

  3. Hi, Great solution. This has kind of been driving me crazy. Do you know of a way to get the ‘Read More’ to appear inline at the end of the excerpt as opposed to on it’s own paragraph line?

    1. these together might work:
      function new_excerpt_more($more) {
      return ' ... ';
      }
      add_filter('excerpt_more', 'new_excerpt_more');

      function excerpt_read_more_link($output) {
      global $post;
      return substr($output,0,-5).'<a href="'. get_permalink($post->ID) . '"> Read All ...</a></p>';
      }
      add_filter('the_excerpt', 'excerpt_read_more_link');

      is a bit of a hack and not widely tested.

  4. Hi

    I have searched a few days to find a way to limit the lenght of each comment when they show up in my feed (rss).

    Is there a way to do this without changig WPs “core files” (or do I have to use php and change the feed.php)?

Leave a Reply to Sven Cancel reply

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