WordPress.org

Support

Support » How-To and Troubleshooting » How to make […] display a link in the_excerpt ?

How to make […] display a link in the_excerpt ?

  • 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!

Viewing 2 replies - 1 through 2 (of 2 total)
  • dannybcastillo

    @dannybcastillo

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

    Kafkaesqui

    @kafkaesqui

    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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to make […] display a link in the_excerpt ?’ is closed to new replies.
Skip to toolbar