DISCLAIMER: this post is older than one year and may not be up to date with latest WordPress version.

Today, here is an useful snippet to replace the ellipsis […] from the excerpt with a permalink to the post.

Paste the following code into your functions.php file. Once saved, the tip will be applied to your blog.

function replace_excerpt($content) {
       return str_replace('[...]',
               '... <div class="more-link"><a href="'. get_permalink() .'">Continue Reading</a></div>',
add_filter('the_excerpt', 'replace_excerpt');

Thanks to CSS Tricks for the great snippet!


One Comment

  1. Lionel Pointet

    Hi there!

    Why not to use the ‘excerpt_more’ filter (see the ‘wp_trim_excerpt’ function, default filter on ‘the_excerpt’)? It’s actually here to override that default ellipsis and will be passed to the wp_trim_words function as $more parameter.

    With that method, you’ll not need to do a str_replace on your entire excerpt.


Leave a Comment

Your email address will not be published. Required fields are marked *