Skip to content

Instantly share code, notes, and snippets.

@jesseeproductions
Last active December 5, 2017 05:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jesseeproductions/2b1af6527b7029eaea6e to your computer and use it in GitHub Desktop.
Save jesseeproductions/2b1af6527b7029eaea6e to your computer and use it in GitHub Desktop.
The Events Calendar Get Events for 1 Year from Today in iCal Export File
/*
* The Events Calendar Get Events for 1 Year from Today in iCal Export File
* add coding to theme's functions.php
* @version 3.12
* trigger export with link: http://yoursite.com/events/?ical=1&year-feed
* change 365 for a different range
*/
add_action( 'pre_get_posts', 'tribe_one_year_ics_export' );
function tribe_one_year_ics_export( WP_Query $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 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment