[wp-trac] [WordPress Trac] #15063: Add a "context" property to WP_Query as a 2nd param to its constructor
WordPress Trac
wp-trac at lists.automattic.com
Thu Oct 7 22:12:45 UTC 2010
#15063: Add a "context" property to WP_Query as a 2nd param to its constructor
--------------------------+-------------------------------------------------
Reporter: mikeschinkel | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Post Types | Version:
Severity: normal | Keywords:
--------------------------+-------------------------------------------------
Through WordPress there's often a need to run a special query using
`WP_Query` but to also modify it using filters like `post_where` and
`post_join`. Unfortunately it's very hard to get the context right and to
only run those filters when needed.
I'd like to propose a new property on WP_Query that adds a context which
we could optionally set when we create WP_Query objects, i.e.:
{{{
$query = new WP_Query('post_type=movie','my-movie-list');
}}}
Then in a filter could do something like this:
{{{
function posts_where($where,$query) {
if (isset($query->context='my-movie-list')) {
// Modify the where clause here...
}
return $where;
}
}}}
Core could then start using it for when calling WP_Query to identify the
context of the query. This could go a long way to helping up make our
sites more robust.
I'll submit a patch if I get interest.
-Mike
--
Ticket URL: <http://core.trac.wordpress.org/ticket/15063>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list