[wp-hackers] filter the_content without affecting the_excerpt

Philip Walton philip at philipwalton.com
Tue Jul 19 22:10:05 UTC 2011


So, I've spent some time digging through the source, and it appears the 
wp_trim_excerpt() function applies 'the_content' filters to the excerpt 
by default. And it looks like there's no getting around it.

Can someone please explain the rational behind not differentiating the 
two? Why should I be forced to apply my content filters to my excerpts 
as well?


On 7/19/11 12:38 PM, Philip Walton wrote:
> In my theme I'm adding a filter to "the_content" to insert social 
> sharing buttons at the beginning of each post, but then when I call 
> the_excert() the text of those buttons is showing up.
>
> I know I can just write another filter on "get_the_excerpt" to remove 
> them, but that just seems wrong.
>
> Is there a way to filter the_content without affecting the_excerpt?


More information about the wp-hackers mailing list