[theme-reviewers] Mini-Site Theme query_posts use

Otto otto at ottodestruct.com
Mon Aug 30 15:33:12 UTC 2010


On Mon, Aug 30, 2010 at 9:59 AM, Philip M. Hofer (Frumph)
<philip at frumph.net> wrote:
> Nevermind I see it, header.php has
>
> //The Query
> query_posts('posts_per_page=10');
>
> Which basically overrides any common loop that occures then does a
> wp_reset_query(), he should be protecting that loops $wp_query and
> restarting the old wp_query after that loop of links happens.
>
> $temp_wp_query = $wp_query;
>
> <code>
>
> $wp_query = temp_wp_query;
>
> sort of thing.
>
> *or* not use query_posts and creates a new WP_Query which is the better way
> of handling that.

You're correct about the better way, but having to save the $wp_query
variable yourself in a temp var is not really necessary, because
that's exactly what wp_reset_query does.

The $wp_query global is just a reference to the $wp_the_query global.
wp_reset_query() basically just unsets the $wp_query and resets it
back to being a reference to the $wp_the_query global.

-Otto


More information about the theme-reviewers mailing list