How To Add Events to Your RSS Feed

Published on: January 13, 2012 | Categories: Tutorial

Hi folks, this will be a quick and short tutorial to show you how to add events to your main RSS feed. The Events Calendar does provide it’s own RSS feed which can be found at http://your-url.com/your-events-slug/feed. But if you want to add events to your main feed (http://your-url.com/feed), follow this simple step…

Add Code to functions.php

Simply 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' );

That should do it! If you have any questions or concerns about this, let me know in the comments.

38 Responses to How To Add Events to Your RSS Feed

  1. Jason says

    The problem we are having is that the Events Calendar RSS feed (http://your-url.com/your-events-slug/feed) only displays the event titles with the date the event was posted–not the actual date/time of the event itself. Therefore, the events appear in the RSS feed the order in which they were posted–not the actual date/time of the event itself. This causes events to appear out of order and also cause old events in the past to appear in the RSS feed.

    To make the Events Calendar RSS feed useful, is it possible to add the date/time of each event to the RSS feed, then sort those events by their date/time, and only include upcoming events?

    • Jonah says

      Hi Jason, I’m not sure if this is possible or how difficult it is – I’ll need to check with some others on the team. Does your (/your-events-url/feed) show in the proper order?

      • Jason says

        @Jonah: No, the events appear in the RSS feed the order in which they were posted–not the actual date/time of the event itself.

        • Jonah says

          Hey Jason, do you have some examples I can look at?

  2. Beth says

    I agree. I wanted to put the RSS feed on another site to show upcoming events. It seems to be in the right order for upcoming events, but the date and time listed are the date and time they were added, not the date and time of the event. It’s a bit confusing for readers who think the events on the list are old.

    http://deals.ingoodcents.com/events/feed

    • Jonah says

      Hi Beth, you’ll need to customize your feed to replace the WordPress date published with the tribe_get_start_date() tag. You can find more info here: http://codex.wordpress.org/Customizing_Feeds

      • Beth says

        Will that effect my regular feed or can I simply customize the calendar feed? I don’t want to change my regular feed.

        • Jonah says

          It sounds like you can modify the feed for a specific post type.

          • Marie says

            I know this may sound a bit wonky of a question, but in the code that codex has, where would you place those tags you mentioned at? Where would it replace it?

            From WP Codex:
            remove_all_actions( ‘do_feed_rss2′ );
            add_action( ‘do_feed_rss2′, ‘acme_product_feed_rss2′, 10, 1 );

            function acme_product_feed_rss2( $for_comments ) {
            $rss_template = get_template_directory() . ‘/feeds/feed-acme_product-rss2.php’;
            if( get_query_var( ‘post_type’ ) == ‘acme_product’ and file_exists( $rss_template ) )
            load_template( $rss_template );
            else
            do_feed_rss2( $for_comments ); // Call default function

            Where would the ( tribe_get_start_date() tag ) go?

  3. Simon says

    Hi there

    How do we add the option to download the events to Outlook etc?

    Regards
    Simon

    • Jonah says

      Hi Simon, the iCal import button should work with newer versions of Outlook. Have you tried clicking the iCal Import button in your setup? If so, and you’re still having problems, what version of Outlook do you have?

      Thanks,
      Jonah

  4. Mark says

    Hi

    Just started using events calendar pro (it’s a very cool plugin). New to this, but also new to feedburner. Does this code allow the events to be dealt with like posts, and let feedburner subscribers have email notifications of new events?

    regards
    Mark

    • Jonah says

      Hi Mark, no this code simply add events into the main WordPress RSS feed.

      Events are already setup to be dealt with like posts (they are a custom post type) and if you have events in your Feedburner feed then users would get email notifications automatically if they have it setup this way.

  5. Bronwyn says

    Are you able to give further detail on what needs to be edited in order to customize this to show the event date rather than the date the event was posted?

    Thanks

  6. Jonah says

    Hey Bronwyn, unfortunately no I cannot give further detail on customizing the actual feed content. You’ll need to read the documentation above on customizing feeds in WordPress. Good luck!

  7. Meghan @JaMonkey says

    Has anyone successfully done this with Genesis as your framework? My site always crashes when I change anything in the Functions.php.

    Also when you say add events to main rss I’m guessing you mean along with posts the events will be sent in the RSS feed as well. (Mine are burnt in Feedburner to be mailed out so I just want to clarify.) Thanks

    • Jonah says

      Hi Meghan, yes I’ve successfully implemented this in the Genesis framework. You must be doing something wrong in the functions.php file. Make sure you follow Genesis’ instructions for building child themes: http://www.studiopress.com/tutorials/building-child-themes

      And yes, this mod is to add events to the main RSS feed along with all other posts.

  8. Rafael says

    Thanks for this tip, it’s exactly what I’m looking for. Unfortunately, the code didn’t work for me. The events are not showing up in the RSS feed. Does anyone have another solution?

    • Rob La Gatta says

      Hey Rafael. Thanks for the note. I know Jonah is out until tomorrow, but I’ll see if he can offer up a response upon his return.

    • Jonah says

      Are you sure you put the code in right place? In your theme’s or child theme’s (if you are using one) functions.php file. Are you getting any error or anything?

  9. Isaac says

    Great mini-tutorial with a great piece of code! I really think that you guys are doing an amazing job and should keep it up! I’m about to add a big calendar on my site, and I’m glad that the results of your hard work is going to enable me to reach my goal.

    I however plan to modify the layout and presentation for it to match my site and all its customized templates 100%.

    But still, all the best with the plugin’s further development!

  10. Terri says

    Just getting my site up, and trying out Event Calendar to see if it will work for my purpose. So far, I think it’s great. I do, however, need to have events feed to the RSS in event date order. I don’t write code… is this something that you guys plan to fix eventually? It seems kind of silly to have an event listing that doesn’t show the events in order by date. Is there a way to export the events list to Excel?

    • Jonah says

      Hi Terri,

      We do order events by event date in the event specific feeds (http://yoururl.com/events/feed, http://yoururl.com/events/category/category_slug/feed) and I’m not quite sure the value of ordering only some posts in your main RSS feed by event date when all the other posts will be ordered normally. But, I’m checking with another developer to see what the feasibility of this is and will post back here when I have an answer. Just know for now that you can access those other feeds where events are ordered correctly by event date.

      Cheers,
      Jonah

      • Sarah Cervantes says

        Ok this functionality is working but not the way it needs to be for me…it is feeding as the date posted not the event date.. IS there a way I can change this so it feeds under the the date of event? not the date I posted?

  11. Sarah Cervantes says

    Ok I used the code in the functions.php form. It states to place the code “Anywhere” I did that and now I can’t even go to my dashboard, all it does is come up with the error message!!!

    Parse error: syntax error, unexpected T_ENDIF in /home/sarah12/yslifeapp.com/wp-content/themes/TP_DESIGN3/functions.php on line 51 What do I do!

    • Jonah says

      Hi Sarah,

      Well, obviously anywhere was not a good place where you put the code! By anywhere you do need to have some feel for PHP code because there is a beginning and end to everything. You must have placed the code in between some already existing code that was not “finished”. Try placing the code at the end of your functions.php file. If there is a closing PHP bracket at the end, place the code before that but after any previous code.

      Hopefully that helps! Let us know how it goes.

      - Jonah

      • Sarah Cervantes says

        Well the site crashed, so what do I do?

        • Jonah says

          Did you try taking the code out and refreshing the website?

          • Sarah Cervantes says

            I can’t even do that…It is yslifeapp.com…I just put in the address and it comes up with the error…Help!

          • Jonah says

            Oh I see, you edited your functions.php from within WordPress… You’ll need to FTP in to the server and change it there.

          • Sarah Cervantes says

            I am using dreamhost, how would I do this?

          • Sarah Cervantes says

            ok I think I got it thanks!

          • Jonah says

            Sounds good Sarah, let me know if there’s anything else you need with this.

  12. Sarah Cervantes says

    how do I do that?

  13. Victor says

    Hi,

    I have successfully add events to my rss feed based on the above codes. But how do I rest of the information of an event? I need the rss feed to include event name, event image, event date, description, and link.

    I get that in line 6 of the code above,
    $args['post_type'] = array(‘post’, ‘tribe_events’);
    pull in the event post date (post) and event name (tribe_events)

    So what are the coded names for event image, event date, description, and link?

    • Jonah West says

      Hi Victor, please post your question to our forum: http://tri.be/support/forums/

      I’m closing out comments on this post since it’s so old. For anyone else that has questions or needs help, please post to the forum.

      Thanks,
      Jonah