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

Dion Hulse (dd32) wordpress at dd32.id.au
Fri Oct 9 06:29:07 UTC 2009

Infact, I'd suggest you DO run wp_reset_query(), As many themes include  
the sidebar after the main loop. The end result is that widgets in the  
sidebar will get your custom loop instead of what you'd expect them to get  
(ie. this posts tags, or the current page in a page widget, etc).

On Fri, 09 Oct 2009 09:34:13 +1100, Chris Jean <gaarai at gaarai.com> wrote:

> Yup. query_posts() is much simpler and bypasses the problems you didn't
> want to deal with. You can always run wp_reset_query() after you are
> done with your custom loop to set $wp_query and all the associated data
> back.
> Chris Jean
> http://gaarai.com/
> http://wp-roadmap.com/
> http://dnsyogi.com/
> Luke Gallagher wrote:
>> Thanks for the feedback guys.
>> The reason I was cloning $wp_query was for connivence so I didn't have
>> to do $new_query->have_posts() etc. query_posts will give me the
>> connivence benefit anyway.
>> After reading the advice from both of you it seems that I should just
>> be using query_posts.
>> Thanks for your help.

Dion Hulse
e: contact at dd32.id.au
w: http://dd32.id.au
WordPressQI: http://wordpressqi.com/

More information about the wp-hackers mailing list