[theme-reviewers] Proper use of pre_get_posts callback

Konstantin Kovshenin kovshenin at gmail.com
Wed Oct 1 21:19:15 UTC 2014


In that case new WP_Query() is just as "incorrect" as query_posts().
Both are used for secondary loops, the former is just a bit more sane
than the latter, but under the hood they're pretty much the exact same
thing.

If the developer needs to alter the main loop, they should be using
the pre_get_posts action, not overwriting the query with something
else. It would also help if you provided a link to the ticket.

On Tue, Sep 30, 2014 at 12:12 PM, priyanshu mittal
<priyanshu.mittal at gmail.com> wrote:
> I am reviewing a theme.
>
> In this theme developer used a slider and masonary layout from the index.php
> file.
>
> He used sticky posts to make up the slider:- for this the seperate wp_query
> object is called and properly resetted via wp_reset_postdata function.
>
> In the masonry layout of posts in order to use his own custom pagination
> function, he used query_posts, to alter the core loop, I know this is not
> the correct way to do it.
>
> My point is should I ask him to create new wp_query object for this or
> should I advice him to use pre_get_posts function.
>
> Thanks
>
> _______________________________________________
> theme-reviewers mailing list
> theme-reviewers at lists.wordpress.org
> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>



-- 
Konstantin


More information about the theme-reviewers mailing list