#4679 closed enhancement (worksforme)
the_content() vs. the_excerpt() - apply different filters to posts without excerpt text specified
Reported by: | fuggi | Owned by: | fuggi |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 2.2.1 |
Component: | Formatting | Keywords: | |
Focuses: | Cc: |
Description
There is a problem with the way that WP handles the excerpt for posts, that do not have a excerpt text specified.
In this case WP applies the wp_trim_excerpt function via default filter which takes the posts content (get_the_content), applies the_content filters and then removes HTML etc.
So this means, that those excerpts will always have the filters for the_content applied and there is now way to prevent it from doing that to have different filters for the_content and the_excerpt (except from writing an excerpt of course).
It would make more sense if WP would not apply the filters for the_content in this case, so that plugin developers have the possibility to apply an other filter to the posts when displayed in the excerpt than when displayed as post. Plugin designers who want to add their action to both content and excerpt (if no own excerpt is written) should have the possibility to add a filter to get_the_content instead.
My plugin WP-Simpleviewer adds a Flash based gallery posts - and when these posts are viewed with the_excerpt() they show up with some javascript/html looking content, however I would like to show something like "Read the whole post to see the gallery".
So IMHO what has to be done is to add the possibility to add filters to get_the_content (according to the codex this does not work yet) and to remove the commented line from function wp_trim_excerpt(formatting.php):
$text = get_the_content(''); //$text = apply_filters('the_content', $text); $text = str_replace(']]>', ']]>', $text);
Attachments (1)
Change History (9)
#5
@
16 years ago
I might be wrong, but isn't that call there on purpose? As in to strip shortcodes and similar stuff that should get discarded?
#6
@
15 years ago
- Component changed from Administration to Formatting
- Keywords needs-patch added; has-patch removed
- Milestone changed from 2.9 to Future Release
#7
@
14 years ago
- Keywords needs-patch removed
- Resolution set to worksforme
- Status changed from accepted to closed
Since this ticket was created, a wp_trim_excerpt
filter was added [10981], which allows plugin authors to completely override the default excerpt generation. I think this resolves the reporters' issue, which was that there was no way to modify generated excerpts.
Two files are changed: formatting.php and post_template.php