[wp-hackers] wp_query gets poisoned by new WP_Query objects

Luke Gallagher notfornoone at gmail.com
Thu Oct 8 13:14:07 UTC 2009


While working with Wordpress I found some odd behaviour, and before I  
continue to get this patched I am wondering if anyone can verify that  
this is actually bug or if it is the intended behaviour of Wordpress.

Here is a previous bug that may be related:
http://core.trac.wordpress.org/ticket/9854

I have verified that the following is the case for the current  
checkout of the Wordpress core.

If I create a custom wp_query object in the default theme's page.php  
file, right after get_header() like so:
http://gist.github.com/204994

and I have a posts_join filter in /wp-content/themes/default/ 
functions.php that prints out to the error_log what type of request  
this is. ( I also tried this out with posts_where and pre_get_posts  
with the same results )

Loading the about page in the web browser I get the following in error  
log:

is_page
is_singular
-------
is_page
is_singular
-------


But if I do it this way I get:
http://gist.github.com/204996

is_page
is_singular
-------
is_archive
is_category
-------


I would think that the latter result is the correct behaviour, should  
be so in the first instance.

Using query_posts instead in the same situation works:
http://gist.github.com/205004

is_page
is_singular
-------
is_archive
is_category
-------

So should I just be using query_posts in this context?
Is there something that I'm missing here?

thanks,

Luke





More information about the wp-hackers mailing list