You’ve used wp_reset_query
, however, you should use wp_reset_postdata
.
wp_reset_query
takes the current query object, and replaces it with the main query. The problem here however, is that you’re using WP_Query, which is a separate individual query object, the main query has not been touched and does not need preserving.
This means we don’t need to call wp_reset_query
, as the query is never changed.
We did call $my_query->the_post
however. This means that the current post data is from your custom query, and needs resetting, so that’s why we call wp_reset_postdata
.
Calling wp_reset_query
when you don’t have to can have unintended consequences, in this case duplication of your posts