WordPress.org

Ready to get started?Download WordPress

Forums

How to make [...] display a link in the_excerpt ? (3 posts)

  1. zavulon
    Member
    Posted 7 years ago #

    Hi all,

    I wanted my main page to display a short summary of the post, and I've used the_exceprt tag for this purpose, and it worked great. However, just one small problem - the_excerpt ends it's "exceprt" with a [...] sign, and I want that [...] to be a clickable link to the actual post. Is there a way to do this?

    Thanks!

  2. dannybcastillo
    Member
    Posted 7 years ago #

    You have more opitions if you use this plugin with excerpts. the_excerpt Reloaded Really easy to use.

  3. Kafkaesqui

    Posted 7 years ago #

    You'll find a number of threads on the forums that discuss how to change this in the WordPress core. Instead, let me pass along a few lines of code so you can do it in your templates.

    Just replace:

    <?php the_excerpt(); ?>

    with this:

    <?php
    $my_excerpt = get_the_excerpt();
    $my_excerpt = str_replace(' [...]', ' <a href="' . get_permalink() . '">[...]</a>', $my_excerpt);
    echo $my_excerpt;
    ?>

    Note: dannybcastillo's suggestion is a good one (after all, it is one of my plugins...), but if the_excerpt() works fine for you, the bit of code above should do.

Topic Closed

This topic has been closed to new replies.

About this Topic