Skip to content

Instantly share code, notes, and snippets.

@joshfeck joshfeck/events_rss.php
Last active Jul 5, 2019

Embed
What would you like to do?
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
You can’t perform that action at this time.