Do you want to add a link to the full article from horizontal ellipsis (3 dots) of your post excerpts? We already know how to change its length, but that ‘…’ could be improved to be more accessible by making it link to the full article.
Instructions:
Add the following to functions.php or in a site-specific plugin. Uncomment the latter return (and comment out the former) if you want to add the link!
<?php add_filter('the_excerpt', 'new_excerpt_hellip'); function new_excerpt_hellip($text) { return str_replace('[...]', '…[+]', $text); //return str_replace('[...]', '…<a href="'. get_permalink($post->ID) . '">[+]</a>', $text); } ?>
Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly copy / paste code snippets in WordPress, so you don’t accidentally break your site.
If you liked this code snippet, please consider checking out our other articles on the site like: Best WordPress Page Builders (Compared).
[code]ID) . '">[+]', $text);
}
?>[/code]
Comments Leave a Reply