[wp-hackers] Filters on get_posts()

scribu mail at scribu.net
Mon Oct 11 14:50:25 UTC 2010

On Mon, Oct 11, 2010 at 5:27 PM, John Blackbourn
<johnbillion+wp at gmail.com<johnbillion%2Bwp at gmail.com>
> wrote:

> On Mon, Oct 11, 2010 at 10:45 AM, scribu <mail at scribu.net> wrote:
> >
> > You can just pass suppress_filters => false to get_posts().
> As I stated this can lead to side effects because many plugins add
> filters to 'posts_where' etc and use global conditionals (which are
> irrelevant to my additional loop) to determine how to filter the
> query. An example might be a plugin that filters 'posts_where' and
> adds an additional clause when is_home() evaluates to true. I don't
> want this clause showing up in my additional loop.

Context is already provided: the wp_query object itself. This was only
introduced in WP 2.9 so most plugins still have to catch up.

get_posts() also sets 'caller_get_posts' => true, so plugins can use that.
In WP 3.1 'caller_get_posts' was then renamed to 'ignore_stickies':


We should probably un-deprecate 'caller_get_posts'.

More information about the wp-hackers mailing list