Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Fixes an unclosed WP_Query() or query_posts() before Advanced Ads loads an ad
* Fix the "Current post is not identical to main post."
* and "Current query is not identical to main query." warnings in Advanced Ads
* caused by custom queries not using wp_reset_postdata() or wp_reset_query()
* @source
* @source
* @source
* Developers should not use this and rather add wp_reset_postdata() or wp_reset_query() to their code
* We are using wp_reset_postdata() because it is less invasive and doesn’t reset the whole query
add_filter( 'advanced-ads-ad-select-args', function( $args ) {
// reset post data
return $args;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment