[wp-hackers] wp_reset_query() (was Complete list of articles)

Otto otto at ottodestruct.com
Tue Feb 5 03:47:31 GMT 2008


On Feb 4, 2008 4:23 PM, Stephen Rider <wp-hackers at striderweb.com> wrote:
> Is there any consensus as to whether people should be using
> wp_reset_query() at the end of custom query_posts() loops?
>
> http://trac.wordpress.org/ticket/4741
>
> The function seems to be a really good idea, and it _is_ implemented
> -- but nobody seems to actually use it....

I've mentioned it on the forums before, but generally speaking I
prefer to discourage the use of query_posts() except to modify the
main loop for special cases. It's really better to create a new
WP_Query object and use that (for those "extra" loops you might happen
to need). That way the main loop for the page stays unmolested.

wp_reset_query() is useful, but only in special cases. Creating a
separate loop is usually more appropriate.

-Otto


More information about the wp-hackers mailing list