Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Otto <otto <at> ottodestruct.com>
Subject: Re: filter the_content without affecting the_excerpt
Newsgroups: gmane.comp.web.wordpress.devel
Date: Tuesday 19th July 2011 22:26:50 UTC (over 5 years ago)
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.

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

-Otto



On Tue, Jul 19, 2011 at 5:10 PM, Philip Walton 
wrote:
> 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?
>
> _______________________________________________
> wp-hackers mailing list
> [email protected]
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
 
CD: 3ms