WordPress.org

Ready to get started?Download WordPress

Forums

the_excerpt (3 posts)

  1. djr3110
    Member
    Posted 5 years ago #

    Hi, I have set my archive page to show the excerpt automatically effectivelly allowing WP to truncate the post after 55 words. All that is cool, but I have comments from some readers that the [...] symbol at the end of the excerpt does hyper link to the post. Unlike the more tag method. Does anyone know how I can make the [...] hyperlink to the post or indeed if I can add Read More using the_excerpt fuction.

    Any help would be great

  2. stvwlf
    Member
    Posted 5 years ago #

    Hi

    Here's some code someone posted the other day that does just that

    Replace Excerpt [...] ellipse with user-defined text
    (put in functions.php)

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

    If, however, you are writing your own excerpts and want to add a Read More permalink, replace:
    <?php the_excerpt(); ?>
    with this:
    <?php the_excerpt(); ?><span class="read_more"><a href="<?php the_permalink(); ?>">[ Read More &rarr; ]</a></span>

  3. djr3110
    Member
    Posted 5 years ago #

    That works like a dream and I've spent so long trying to find a solution thank you so much

Topic Closed

This topic has been closed to new replies.

About this Topic