Skip to content

Instantly share code, notes, and snippets.

@codearachnid
Created September 15, 2012 11:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codearachnid/3727382 to your computer and use it in GitHub Desktop.
Save codearachnid/3727382 to your computer and use it in GitHub Desktop.
Tri.be event calendar pre_get_posts fix
<?php
/**
*
* In cases where pre_get_posts changes the 'post_type' query var to post (or another post type)
* if the original query 'post_type' is 'tribe_events' then reset so that the calendar list views
* continue to work properly.
*
*/
add_filter('pre_get_posts', 'tribe_fix_pre_get_posts_reset');
function tribe_fix_pre_get_posts_reset($query){
if( isset($query->query['post_type']) && $query->query['post_type'] == TribeEvents::POSTTYPE) {
$query->set('post_type',TribeEvents::POSTTYPE);
}
return $query;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment