[wp-hackers] Loops and Cloning

Otto otto at ottodestruct.com
Mon Nov 3 14:59:37 GMT 2008


On Sun, Nov 2, 2008 at 10:27 AM, Malaiac <malaiac at gmail.com> wrote:
> $myquery = new WP_Query('queryvars=whatever');
> and :
> add_filter('posts_where','my_function'); > apply to all wp_query objects
>
> function my_function($where_string)
> {
> // ok... now I want to act on the where only IF i'm in $myquery and
> not $wp_query

Wrong place. You should add and remove your filter accordingly.

add_filter('posts_where','my_function');
$myquery = new WP_Query('queryvars=whatever');
// insert a Loop here
remove_filter('posts_where','my_function');


More information about the wp-hackers mailing list