the_content() vs. the_excerpt() - apply different filters to posts without excerpt text specified
|Reported by:||fuggi||Owned by:||fuggi|
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.
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);
Change History (9)
- Component changed from Administration to Formatting
- Keywords needs-patch added; has-patch removed
- Milestone changed from 2.9 to Future Release
5 years ago
- Keywords needs-patch removed
- Resolution set to worksforme
- Status changed from accepted to closed