• I’ve been trying for ages to manage this and just can’t figure it out from reading over the Codex!

    Basically I like the idea of using the_excerpt() as it automatically trims your post to a specific length. But what I don’t like is the way that there are no parameters available to add a ‘read more’ link.

    I’ve tried using the_content('Read More') but I hate the way that you have to use the ‘more’ quicktag in the editor!

    Is there no way of adding a ‘read more’ link automatically to the_excerpt() if it is over the length defined in functions.php?

    Thanks to anyone who can help

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi

    Put this code in your theme’s functions.php file.

    function excerpt_ellipse($text) {
       return str_replace('[...]', ' <a href="'.get_permalink().'">Read more...</a>', $text); }
    add_filter('the_excerpt', 'excerpt_ellipse');

    It automatically does a search and replace on the text returned by the_excerpt, substituting a readmore link for [...]. In the code you can change “Read more…” to whatever you want displayed as the link text.

    Thread Starter 000000000

    (@pealo86)

    Thanks I’ll give it a shot! I had previously tried this:

    function new_excerpt_more($more) {
    	return '[.....]';
    }
    add_filter('excerpt_more', 'new_excerpt_more');

    But nothing seemed to happen! Was it intended to serve the same sort of purpose?

    Either way I’ll try out what you said, thanks.

    luke-janicke

    (@luke-janicke)

    pealo86, I also couldn’t get new_excerpt_more to work.
    stvwlf, your method worked for me. thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Using ‘read more’ link with the excerpt’ is closed to new replies.