Opened 16 years ago
Last modified 2 weeks ago
#12084 new enhancement
allow preserving HTML in the_excerpt (specify allowed tags for strip_tags in wp_trim_excerpt)
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | 3.0 |
| Component: | Formatting | Keywords: | has-patch |
| 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)
Change History (10)
#1
@
16 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)
#2
@
16 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.
#4
@
14 years ago
- Keywords changed from has-patch, needs-testing to has-patch needs-testing
Duplicate: #21558
#6
@
3 months ago
- Keywords needs-testing removed
Added needs-refresh by @chriscct7, so needs-testing should also be removed.
#7
@
3 weeks ago
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.
This ticket was mentioned in PR #11438 on WordPress/wordpress-develop by @abcd95.
2 weeks ago
#8
- Keywords needs-refresh removed
Creates excerpt_tags filter for wp_trim_content