Code Snippet
Replace Excerpt Ellipsis with Permalink
This is useful if you would like to replace the ellipsis [...] from the excerpt with a permalink to the post.
functions.php addition:
function replace_excerpt($content) {
return str_replace('[...]',
'<div class="more-link"><a href="'. get_permalink() .'">Continue Reading</a></div>',
$content
);
}
add_filter('the_excerpt', 'replace_excerpt');
Very useful, tried and tested, thanks.
win!
Useful snippet, thanks!
where do yo place this function?
I’ve been using:
function new_excerpt_more($more) {
global $post;
return ‘… a class=”more-link” href=”‘. get_permalink($post->ID) . ‘”>’ . ‘Read More »’ . ‘/a’;
}
add_filter(‘excerpt_more’, ‘new_excerpt_more’);
But it kept showing the ” … ” at the end of the post.
This is much cleaner. Thanks!
Hello,
Thank you for all your tricks, you save us so much time!
Any impact on SEO when using this one please?
Regards,
DigWP
A book and blog co-authored by Jeff Starr and myself about the World's most popular publishing platform.
Quotes on Design
Design, like Art, can be an elusive word to define and an awfully fun thing to have opinions about.
HTML-Ipsum
One-click copy to clipboard access to Lorem Ipsum text that comes wrapped in a variety of HTML.
Bookshelf
Hey Chris, what books do you recommend? These, young fertile mind, these.