[wp-hackers] filter the_content without affecting the_excerpt

Philip Walton philip at philipwalton.com
Tue Jul 19 23:07:10 UTC 2011

On 7/19/11 3:26 PM, Otto wrote:
> The purpose of wp_trim_excerpt is to create an artificial excerpt if
> one doesn't exist for the post. So it applies the content filters to
> the content, then trims it down to create the excerpt.If there is an
> explicit excerpt on the post, then the content filters will not be
> applied to that, nor will the content even get pulled.
> So if you're adding something to the beginning of the content, then it
> will be in the created excerpt. This is by design.
I understand that for many if not even most situations, anything you add 
to the content you probably also want to add to the excerpt. I get that.

My issue is that it's impossible to not do it this way. It would be 
great if there were a filter for "after_the_content" or 
"post_the_content" or something like that allowing you to just filter 
the content and leave the excerpt alone.

Having wp_trim_excerpt() filter "get_the_content" instead of 
"the_content" makes more sense to me, though I understand it's 
impossible to change it at this point.

> If you don't want it to do that, use a shortcode to insert your
> content. Shortcodes get stripped from auto-created excerpts.
> -Otto

More information about the wp-hackers mailing list