Soft Reject - wp_reset_query

Hi guys!

I hope you can give me an explanation of this issue. I had a soft rejection in themeforest and one reason was:

wp_reset_query - if you’re not using query_posts(), then you really shouldn’t be messing with the main $wp_query variable, as wp_reset_query() does.

I’m using query_posts() in a page template for displaying the main query so I assume that I have to use wp_reset_query. Or they are telling me that I don’t have to use both query_posts() and wp_reset_query.

Thanks in advance!

Maybe you’re using wp_reset_query in other place? BTW, why not to use WP_Query ?

Use WP_Query as @kotofey suggested

https://codex.wordpress.org/Class_Reference/WP_Query

One more clarification: if you’re using query_posts() then you must to use wp_reset_query(). When you’re using WP_Query (which more prefer) then don’t forget to use wp_reset_postdata();

I think, that the reviewer wrote this so you re-check this function in your code again. I’m not sure this is a reason for soft-reject. Just the hint from him to avoid another soft-reject if you’re using this function when you don’t need to do it.

Thanks to all! Finally I changed query_posts() to WP_Query.