Last active
December 5, 2017 05:18
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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