[wp-trac] [WordPress Trac] #12084: allow preserving HTML in the_excerpt (specify allowed tags for strip_tags in wp_trim_excerpt)

WordPress Trac noreply at wordpress.org
Thu Apr 2 12:32:05 UTC 2026


#12084: allow preserving HTML in the_excerpt (specify allowed tags for strip_tags
in wp_trim_excerpt)
-------------------------------------+---------------------
 Reporter:  sillybean                |       Owner:  (none)
     Type:  enhancement              |      Status:  new
 Priority:  normal                   |   Milestone:
Component:  Formatting               |     Version:  3.0
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-refresh  |     Focuses:
-------------------------------------+---------------------

Comment (by abcd95):

 I think we should have a single excerpt_allowed_tags filter inside
 wp_trim_excerpt(), defaulting to `''` (strip everything — identical to
 current behaviour). When non-empty, bypass wp_trim_words(), strip only
 disallowed tags, find the word-boundary cut point on a plain-text copy,
 then run force_balance_tags() before appending the more string.

 I am working on this fix and testing some changes; the PR should be up
 shortly.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/12084#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list