Skip to content

Instantly share code, notes, and snippets.

@elimn
Last active April 21, 2016 21:54
Show Gist options
  • Save elimn/532aa266f1a74463509b to your computer and use it in GitHub Desktop.
Save elimn/532aa266f1a74463509b to your computer and use it in GitHub Desktop.
MT | TEC | Export 1 year of iCal events from The Events Calendar
<?php
/*
* The Events Calendar Get Events for 1 Year from Today in iCal Export File
* add coding to theme's functions.php
* To trigger the export go to this URL: http://yoursite.com/events/?ical=1&year-feed
* You can change 365 (days) to export more or less events
*/
function tribe_one_year_ics_export( $query ) {
if ( ! isset( $_GET['ical'] ) || ! isset( $_GET['year-feed'] ) ) {
return;
}
if ( ! isset( $query->tribe_is_event_query ) || ! $query->tribe_is_event_query ) {
return;
}
$query->set( 'eventDisplay', 'custom' );
$query->set( 'start_date', 'now' );
$query->set( 'end_date', " + 365 day" );
$query->set( 'posts_per_page', - 1 );
}
add_action( 'pre_get_posts', 'tribe_one_year_ics_export' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment