Skip to content

Instantly share code, notes, and snippets.

@joshfeck
Last active July 5, 2019 20:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshfeck/ffba0d66fa72af45b459e5d5cc586196 to your computer and use it in GitHub Desktop.
Save joshfeck/ffba0d66fa72af45b459e5d5cc586196 to your computer and use it in GitHub Desktop.
Change the Events RSS feed pubDate for each event item. Event Espresso 4.
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
function change_post_time_to_event_start($time, $d, $gmt) {
global $post;
$event = EEH_Event_View::get_event($post->ID);
if($event instanceof EE_Event) {
$primary_datetime = clone $event->primary_datetime();
$time = $primary_datetime->start_date_and_time('Y-m-d', 'H:i:s');
}
return $time;
}
add_action('rss2_ns','extra_feed_type_event');
function extra_feed_type_event(){
if (EE_Registry::instance()->REQ->is_set('post_type')) {
if(EE_Registry::instance()->REQ->get('post_type') == 'espresso_events') {
echo 'xmlns:ev="http://purl.org/rss/1.0/modules/event/"';
add_filter('get_post_time', 'change_post_time_to_event_start', 10, 3);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment