How to use WP_Query without breaking the main Query

Question

The WP Query class can be used to make almost any imaginable query to the WP database. It’s amazing.

But it’s also used when WordPress is loaded, to run the main query for the current page request.

A common practice is to use wp_reset_query() and/or wp_reset_postdata()

But it’s unclear when to use one or the other, or if they must be used at all. And I don’t want to use them just in case but only when they are really needed.

So I would like to know what is the correct way to use the power of WP Query without breaking the main query.

0
Alvaro Franz 2 months 2021-05-30T07:13:43-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse