How to prevent WordPress from stripping HTML tags in post excerpts
I am using wp_trim_words() to trim excerpts on my homepage. It works fine except that it strips HTML tags from the excerpts. I need to keep certain pieces of the excerpt bold (using <strong>). Following the instructions here, I tried replacing the wp_trim_words function with custom code where $text = wp_strip_all_tags( $text ); is changed to $text = strip_tags($text, '<strong>');. However, this breaks the site. What am I doing wrong? // Remove Reverie Trim Words function remove_trim_words() { remove_filter('get_the_excerpt', 'wp_trim_words'); add_filter('get_the_excerpt', 'oakwood_trim_words')
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.