OK, I see the place where the query is being reset near the end of the [loop] shortcode. On line 759 of ccs-loop.php:
wp_reset_query();
wp_reset_postdata();
It’s possible that using both of these functions is interfering with your main loop. Could you try commenting out wp_reset_query
and see if that straightens out the nested loops?
On my test site, I display an archive of posts (main loop in template) and several of the posts use the [loop] shortcode inside as secondary loops. They’re all displaying fine, with or without wp_reset_query
.
I’ve checked the Codex, and I see why I used both wp_reset_query and wp_reset_postdata.
wp_reset_query() restores the $wp_query and global post data to the original main query.
wp_reset_postdata() restores the global $post variable of the main query loop after a secondary query loop using new WP_Query. It restores the $post variable to the current post in the main query.
In both descriptions, there is an example of using WP_Query for a secondary loop, then restoring the main query using one or the other function.
—
I’ve looked into the core code to see exactly the difference between these two functions: wp_reset_query
restores global $wp_query, then calls wp_reset_postdata
, so definitely having both is redundant. I believe only the latter is necessary. I’ll set up more tests and update the plugin after I confirm this.