I have a theme where I need multiple queries for each column. Is it better to modify the main query with pre_get_post and reset the loop or create a new query for each of my columns?
I think that you are making some confusion between main query and secondary queries in Wordpress. Maybe read this can help you to better understand.
In short when you visit an url of your site, that url make wordpress fires a query on db: this is the main query.
Thanks to the action
pre_get_post you can modify the main query, e.g. adding, removing or edit query vars before the query is runned on db.
But once the query fired, the only chance to recreate a query that you can call 'main' 1 (even if is not triggered by url) is use
query_posts, but this practice is highly not recommended.
So if your question is: "Should I use new
WP_Query instances for multiple queries or should I use multiple
The answer is, surely, new
1 You can call 'main' the query runned by
query_posts, because the main query, is characterized from 2 aspects (besides the fact that normally is triggered by the url):
- It's an object (an instance of
WP_Querymore precisely) named
$wp_queryin the global scope. (You can access to it using
- You can cycle the posts handled by this query using the loop.
Once the query you obtain using
query_posts have both these characteristics, it is fledged the main query, even if is not triggered by url.