Knowledgebase

Check the knowledge base articles to get a jump start on your integrations, modifications, and all around user questions. If you don’t find what you’re looking for hit the forums.

Search Knowledgebase

RSS Feed

Hi folks, this tutorial will show you how to add events to your main RSS feed or add the event’s start and end times to the Events Feed. The Events Calendar provides its own RSS feed which can be found at http://your-url.com/your-events-slug/feed.

If you want to add events to your main feed (http://your-url.com/feed), follow this simple step, open up your theme’s functions.php file and add the following code anywhere you like:

/*-----------------------------------------------------------------------------------*/
/* Add Events to RSS Feed
/*-----------------------------------------------------------------------------------*/
function add_events_to_rss_feed( $args ) {
  if ( isset( $args['feed'] ) && !isset( $args['post_type'] ) )
    $args['post_type'] = array('post', 'tribe_events');
  return $args;
}

add_filter( 'request', 'add_events_to_rss_feed' );

The feeds do not automatically include the event start and end date/times, but you can easily add these by tapping in to the WordPress feed hooks. To add the event start and end date/times, add the following to your theme’s functions.php file:

// Add Tribe Event Namespace
add_filter( 'rss2_ns', 'events_rss2_namespace' );

function events_rss2_namespace() {
    echo 'xmlns:ev="http://purl.org/rss/2.0/modules/event/"'."rn";
}

// Add Event Date to RSS Feeds
add_action('rss_item','tribe_rss_feed_add_eventdate');
add_action('rss2_item','tribe_rss_feed_add_eventdate');
add_action('commentsrss2_item','tribe_rss_feed_add_eventdate');

function tribe_rss_feed_add_eventdate() {
  if ( ! tribe_is_event() ) return;
  ?>
  <ev:tribe_event_meta xmlns:ev="Event">
  <?php if (tribe_get_start_date() !== tribe_get_end_date() ) { ?>

    <ev:startdate><?php echo tribe_get_start_date(); ?></ev:startdate>
    <ev:enddate><?php echo tribe_get_end_date(); ?></ev:enddate>

  <?php } else { ?>

    <ev:startdate><?php echo tribe_get_start_date(); ?></ev:startdate>

  <?php } ?>
  </ev:tribe_event_meta>

<?php }

There is no limit to any other information you want to add to your events feed. For more information on customizing feeds, I highly recommend this article.

One final adjustment you may wish to make is to ensure that events, just like posts, are ordered by publication date. An extra snippet can be put in place for that very purpose (if that’s what you want to achieve, of course):

add_action( 'pre_get_posts', 'maybe_teardown_tribe_order_filter', 60 );

function maybe_teardown_tribe_order_filter() {
	if ( is_feed() ) remove_filter( 'posts_orderby', array( 'TribeEventsQuery', 'posts_orderby' ), 10, 2 );
}

This basically tells The Events Calendar not to interfere with the order when events are included.

Good luck!