[wp-hackers] Sidebar/Widget conditionnal tag?

Philip M. Hofer (Frumph) philip at frumph.net
Wed Jan 5 06:32:41 UTC 2011

or, he could remove_filter before the loop he doesn't want it in and add 
again afterwards ;/

----- Original Message ----- 
From: "Mike Schinkel" <mikeschinkel at newclarity.net>
To: <wp-hackers at lists.automattic.com>
Sent: Tuesday, January 04, 2011 1:47 PM
Subject: Re: [wp-hackers] Sidebar/Widget conditionnal tag?

> On Jan 4, 2011, at 4:33 PM, Olivier wrote:
>> The issue is that I have no way to differentiate between the main
>> content loop and the sidebar widget loop because there is no flag
>> specific to each. So when my filter applies, it applies to both and
>> therefore is not efficient because I should have different filters for
>> both to make this work.
> Common problem, easy and much more robust solution (assuming you are 
> calling WP_Query or get_posts() in your widget.) Subclass WP_Query and use 
> instance variables to control state and/or add the filters before you call 
> the instance method get_posts() and remove the filters immediately after.
> This answer can show you how:
> http://wordpress.stackexchange.com/questions/6162/#6171
> Hope this helps.
> -Mike
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers

More information about the wp-hackers mailing list