Skip to content

Instantly share code, notes, and snippets.

@caseydriscoll
Created June 27, 2014 17:54
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save caseydriscoll/20e7f714b90cd8c56d56 to your computer and use it in GitHub Desktop.
Save caseydriscoll/20e7f714b90cd8c56d56 to your computer and use it in GitHub Desktop.
Tribe Unlimited iCal Feed
class UnlimitedICalFeed {
public static function setup() {
add_action( 'pre_get_posts', array( __CLASS__, 'pre_get_posts' ), 75 );
}
public static function pre_get_posts( WP_Query $query ) {
if ( ! $query->tribe_is_event_query ) return self::shutdown();
if ( ! isset($_GET['ical'] ) || 'all' !== $_GET['ical'] ) return self::shutdown();
$query->set( 'posts_per_page', -1 );
}
protected static function shutdown() {
remove_action( 'pre_get_posts', array( __CLASS__, 'pre_get_posts' ), 75 );
return null;
}
}
UnlimitedICalFeed::setup();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment