Tribe__Events__Templates::restoreQuery()
Restore the original query after spoofing it.
Source
File: src/Tribe/Templates.php
public static function restoreQuery() {
$wp_query = tribe_get_global_query_object();
// If the query hasn't been spoofed we need take no action
if ( ! isset( $wp_query->spoofed ) || ! $wp_query->spoofed ) {
return;
}
// Remove the spoof post and fix the post count
array_pop( $wp_query->posts );
$wp_query->post_count = count( $wp_query->posts );
// If we have other posts besides the spoof, rewind and reset
if ( $wp_query->post_count > 0 ) {
$wp_query->rewind_posts();
wp_reset_postdata();
}
// If there are no other posts, unset the $post property
elseif ( 0 === $wp_query->post_count ) {
$wp_query->current_post = -1;
unset( $wp_query->post );
}
// Don't do this again
unset( $wp_query->spoofed );
}