Make WordPress Core

Opened 15 years ago

Last modified 6 years ago

#12084 new enhancement

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

Reported by: sillybean's profile sillybean Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.0
Component: Formatting Keywords: has-patch needs-testing needs-refresh
Focuses: 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 (2)

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

Download all attachments as: .zip

Change History (7)

@sillybean
15 years ago

Creates excerpt_tags filter for wp_trim_content

#1 @sillybean
15 years ago

  • 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)

@sillybean
15 years ago

balances tags after truncating excerpt

#2 @sillybean
15 years ago

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.

#3 @nacin
15 years ago

  • Milestone changed from Unassigned to Future Release

#4 @ocean90
12 years ago

  • Keywords changed from has-patch, needs-testing to has-patch needs-testing

Duplicate: #21558

#5 @chriscct7
9 years ago

  • Keywords needs-refresh added
  • Severity changed from minor to normal
Note: See TracTickets for help on using tickets.