ThemeShaper Forums » Thematic

[closed]

'Read more' link in excerpt redux

(13 posts)
  • Started 9 years ago by Marcus
  • Latest reply from noumaan
  • This topic is resolved
  1. Marcus
    Member

    I am trying to replace the annoying [...] auto-appended at the end of excerpts with a 'read more' link that clicks through to the full post. This bit of code is floating around in various forums that seems to work for others:

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

    Seems simple enough, but when I drop it in my child theme's functions.php, my excerpts stay the same, still with the [...]

    Is there something about how Thematic handles excerpts differently that would prevent the above from working? Is there something else I need to filter that I'm not aware of?

    Thanks much!

    Posted 9 years ago #
  2. Hi,

    Thematic is using get_the_expert() .. change your last line to:

    add_filter('get_the_excerpt', 'excerpt_ellipse');

    Chris

    Posted 9 years ago #
  3. Marcus
    Member

    Thank you so much, Chris. That did it. Your dedication to these forums is invaluable, and Thematic is a tremendous tool.

    Posted 9 years ago #
  4. How about making the excerpts on category/archives pages also end with a clickable "read more..."?

    Posted 9 years ago #
  5. jconroy
    Member

    When I use Marcus' filter I end up with an extra line break before the read more link. Any ideas what would be doing it?. If I remove the filter the [...] is back and the line break is gone.

    Posted 9 years ago #
  6. Testing the code above I don't see the line break. Maybe its a copy & paste problem. There is line wrap in the code above before the "read more" bit. I can't see why it'd matter but try removing all the extra spaces between <a href="'.get_permalink().'"> and Read more ...</a>'

    Posted 9 years ago #
  7. jconroy
    Member

    Thanks for the response em hr - tried that initially. Still no good.

    I also cannot change the excerpt length using the following snipped (and with other plugins) which is frustrating me to no end.

    function new_excerpt_length($length) {
    return 20;
    }
    add_filter('excerpt_length', 'new_excerpt_length');

    Posted 9 years ago #
  8. jconroy
    Member

    Ok Seems like something weird is going on with the child theme I am working on. All the functions are working another clean install.

    Posted 9 years ago #
  9. jconroy
    Member

    Found the culprit - wordTube. Deactivated it and all the excerpt functionality is working properly.

    Posted 9 years ago #
  10. Thanks! Here is what I added to my Acamas functions.php"


    function childtheme_content($content) {
    if (is_home() || is_front_page()) {
    $content= 'excerpt';}
    return $content;
    }
    add_filter('thematic_content', 'childtheme_content');

    function excerpt_ellipse($text) {
    return str_replace('[...]', '
    Read more ...
    ', $text); }
    add_filter('get_the_excerpt', 'excerpt_ellipse');

    function new_excerpt_length($length) {
    return 20;
    }
    add_filter('excerpt_length', 'new_excerpt_length');

    Posted 9 years ago #
  11. I am a total newbie to child theme development.

    I have a question, using @whatsthebigidea's code I am able to get the excerpts with Read more at the end. Now how do I make this Read more a link to the post?

    Posted 7 years ago #
  12. Looks like his code got mangled and the link turned active.

    <a href="'.get_permalink().'" class="more-link">Read more &raquo;</a>

    Will link to the post, although feel free to modify the class and Read More text

    Posted 7 years ago #
  13. @scottNix Thank you it worked

    Posted 7 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.