I’m having a problem with the_excerpt and can not find the answer anywhere…
I simply want to allow links to be clickable when they are displayed via the_excerpt! There has to be a function for this, rather than relying on a plugin. But I can’t find it and the advanced excerpt plugins are so complex that I am unable to find the small snippet which makes this work.
Leave a Reply
You must be logged in to post a comment.
You can use the script I found here:
http://aaronrussell.co.uk/legacy/improving-wordpress-the_excerpt/
I’ve modified it to show links in the excerpt, and removed some of the other functions:
The part that fixes it is
$text = strip_tags($text, '<a>');
. along withremove_filter('get_the_excerpt', 'wp_trim_excerpt');
You can use the following plugin for allowing links and other html tags in the excerpts
Plugin: Show links in excerpts wordpress
I have no affiliation regarding the plugin
The code basically allows a list of comma separated HTML tags to work in your excerpts which are normally stripped by WordPress. Tested on Genesis and works.
Source http://daan.kortenba.ch/add-tags-to-genesis-content-limit-in-content-archives/
WordPress strips out tags in
wp_trim_words()
, which is called byget_the_excerpt()
; so we have to filter ‘wp_trim_words’, basically copying that function with one change: replacewp_strip_all_tags()
withstrip_tags()
.We don’t want other functions that run
wp_trim_words
to be modified, so we add our filter whileget_the_excerpt()
is running, and remove it when we’re done.I wrote this gist after reviewing other suggested methods, because I think this is a more targeted solution. The gist will be updated going forward.