Ticket #12084 (new enhancement)

Opened 2 years ago

Last modified 23 months ago

allow preserving HTML in the_excerpt (specify allowed tags for strip_tags in wp_trim_excerpt)

Reported by: sillybean Owned by:
Priority: normal Milestone: Future Release
Component: Formatting Version: 3.0
Severity: minor Keywords: has-patch, needs-testing
Cc:

Description

Right now, wp_trim_excerpt is destructive. You can filter it, but once tags are stripped, you can't get them back without recreating the excerpt from the raw input. It would be nice if theme developers had an option to preserve at least some of the HTML formatting when using excerpts as post teasers (see #9260).

Attachments

excerpt_tags.diff Download (624 bytes) - added by sillybean 2 years ago.
Creates excerpt_tags filter for wp_trim_content
excerpt_tags2.diff Download (1.0 KB) - added by sillybean 2 years ago.
balances tags after truncating excerpt

Change History

Creates excerpt_tags filter for wp_trim_content

  • Summary changed from allow preserving HTML in the_excerpt (make strip_tags optional in wp_trim_excerpt) to allow preserving HTML in the_excerpt (specify allowed tags for strip_tags in wp_trim_excerpt)

balances tags after truncating excerpt

Second patch balances the tags after the excerpt has been truncated, which makes more sense. However, it can result in weirdness with the word count. Not sure how to get around that without some really painful regex.

This patch also preserves shortcodes in excerpts, which seems logical if we're allowing HTML.

  • Milestone changed from Unassigned to Future Release
Note: See TracTickets for help on using tickets.