Skip to content

Instantly share code, notes, and snippets.

@jo-snips
Created November 12, 2012 18:27
Show Gist options
  • Select an option

  • Save jo-snips/4060995 to your computer and use it in GitHub Desktop.

Select an option

Save jo-snips/4060995 to your computer and use it in GitHub Desktop.
The Events Calendar: Customize RSS Date Range
<?php
add_action( 'pre_get_posts', 'show_one_year_of_events' );
function show_one_year_of_events( $query ) {
if ( $query->is_feed && empty( $query->query_vars['suppress_filters'] ) ) {
$query->set('meta_query', array(
'relation' => 'OR',
array(
'key' => '_EventStartDate',
'value' => array(
date('Y-m-d H:i:s', strtotime('now')),
date('Y-m-d H:i:s', strtotime('+1 weeks'))),
'compare' => 'BETWEEN',
'type' => 'DATETIME'
),
array(
'key' => '_EventEndDate',
'value' => array(
date('Y-m-d H:i:s', strtotime('now')),
date('Y-m-d H:i:s', strtotime('+1 weeks'))),
'compare' => 'BETWEEN',
'type' => 'DATETIME'
)
)
);
}
return $query;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment