[wp-trac] [WordPress Trac] #14869: Adding a "callback" to WP_Query()
WordPress Trac
wp-trac at lists.automattic.com
Tue Sep 14 17:15:00 UTC 2010
#14869: Adding a "callback" to WP_Query()
--------------------------+-------------------------------------------------
Reporter: mikeschinkel | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Query | Version:
Severity: normal | Keywords: close
--------------------------+-------------------------------------------------
Changes (by scribu):
* keywords: => close
Comment:
I agree with filosofo. Here's a snippet that practically does what you're
asking for:
{{{
function my_posts_where( $where, $wp_query ) {
if ( $wp_query !== $GLOBALS['my_wp_query'] )
return $where;
// this will only execute for $my_wp_query
}
add_filter('posts_where', 'my_posts_where', 10, 2);
global $my_wp_query;
$my_wp_query = new WP_Query(' ... ');
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/14869#comment:2>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list