X
378746

Trying to create event rss feed but not finding some meta data

Hi there, I’m trying to create an RSS feed of events on my website, see here: https://fatherheart.net/?feed=eventon

As you can see its not displaying dates, speakers and location.

Any idea what I’m doing wrong? The subtitle is working, but not the other meta data.

BY: Tom Carroll - Feb 13,2025 AT 10:18PM - 1 month ago
    • Tom Carroll Feb 13,2025 AT 10:18PM - Posted 1 month ago - #378747

      I created a snippet to generate the feed:

      /**
      * EVENTON CUSTOM RSS FEED
      *
      * Add this code to your theme’s functions.php file or a custom plugin.
      *
      * This snippet does the following:
      * 1. Registers a new RSS feed endpoint (e.g. https://fatherheart.net/?feed=eventon).
      * 2. Outputs an RSS feed that loops through EventON events and includes:
      * – Start Date
      * – End Date
      * – Location
      * – Subtitle
      * – Speakers
      *
      * The snippet now checks for an “all day” flag (evcal_allday) so that if an event is
      * all day, the dates are formatted using only the date (matching the display in the event card).
      *
      * Refer to https://docs.myeventon.com/documentations/event-post-meta-variables/ for a list of meta variables.
      */

      // Register a new feed endpoint.
      function my_eventon_add_feed(){
      add_feed(‘eventon’, ‘my_eventon_feed_template’);
      }
      add_action(‘init’, ‘my_eventon_add_feed’);

      // Create the feed template function.
      function my_eventon_feed_template(){
      // Set the proper content type.
      header(‘Content-Type: application/rss+xml; charset=’ . get_option(‘blog_charset’), true);

      // Query your EventON events.
      $args = array(
      ‘post_type’ => ‘ajde_events’, // Change this if your EventON post type is different.
      ‘posts_per_page’ => 50, // Adjust number of events as needed.
      ‘orderby’ => ‘date’,
      ‘order’ => ‘DESC’
      );
      $events = new WP_Query($args);

      // Output the RSS XML.
      echo ‘<?xml version=”1.0″ encoding=”‘ . get_option(‘blog_charset’) . ‘”?’ . ‘>’; ?>
      <rss version=”2.0″>
      <channel>
      <title><?php bloginfo_rss(‘name’); ?> – EventON Events</title>
      <link><?php bloginfo_rss(‘url’); ?></link>
      <description><?php bloginfo_rss(“description”); ?></description>
      <language><?php bloginfo_rss(‘language’); ?></language>
      <lastBuildDate><?php echo mysql2date(‘r’, get_lastpostmodified(‘GMT’)); ?></lastBuildDate>
      <?php while($events->have_posts()) : $events->the_post();
      $post_id = get_the_ID();

      // Retrieve event dates (assumed to be stored as Unix timestamps).
      $start_date_meta = get_post_meta($post_id, ‘evcal_start_date’, true);
      $end_date_meta = get_post_meta($post_id, ‘evcal_end_date’, true);

      // Check if the event is “all day” (meta key: evcal_allday).
      $allday = get_post_meta($post_id, ‘evcal_allday’, true);
      if($start_date_meta && is_numeric($start_date_meta)){
      if($allday == ‘yes’){
      $formatted_start_date = date_i18n(get_option(‘date_format’), $start_date_meta);
      } else {
      $formatted_start_date = date_i18n(get_option(‘date_format’) . ‘ ‘ . get_option(‘time_format’), $start_date_meta);
      }
      } else {
      $formatted_start_date = ‘N/A’;
      }
      if($end_date_meta && is_numeric($end_date_meta)){
      if($allday == ‘yes’){
      $formatted_end_date = date_i18n(get_option(‘date_format’), $end_date_meta);
      } else {
      $formatted_end_date = date_i18n(get_option(‘date_format’) . ‘ ‘ . get_option(‘time_format’), $end_date_meta);
      }
      } else {
      $formatted_end_date = ‘N/A’;
      }

      // Retrieve location.
      $location = get_post_meta($post_id, ‘evcal_location’, true);
      $formatted_location = $location ? esc_html($location) : ‘N/A’;

      // Retrieve subtitle.
      $subtitle = get_post_meta($post_id, ‘evcal_subtitle’, true);
      $formatted_subtitle = $subtitle ? esc_html($subtitle) : ‘N/A’;

      // Retrieve speakers (if stored as a simple meta field).
      $speakers = get_post_meta($post_id, ‘evcal_event_speakers’, true);
      if(is_array($speakers)){
      $formatted_speakers = implode(“, “, $speakers);
      } else {
      $formatted_speakers = $speakers ? $speakers : ‘N/A’;
      }
      ?>
      <item>
      <title><?php the_title_rss(); ?></title>
      <link><?php the_permalink_rss(); ?></link>
      <pubDate><?php echo mysql2date(‘r’, get_the_date(‘Y-m-d H:i:s’)); ?></pubDate>
      <guid isPermaLink=”false”><?php the_guid(); ?></guid>
      <description><![CDATA[
      <?php the_excerpt_rss(); ?>
      <br /><br />
      <strong>Start Date:</strong> <?php echo esc_html($formatted_start_date); ?><br />
      <strong>End Date:</strong> <?php echo esc_html($formatted_end_date); ?><br />
      <strong>Location:</strong> <?php echo $formatted_location; ?><br />
      <strong>Subtitle:</strong> <?php echo $formatted_subtitle; ?><br />
      <strong>Speakers:</strong> <?php echo esc_html($formatted_speakers); ?><br />
      ]]></description>
      </item>
      <?php endwhile; wp_reset_postdata(); ?>
      </channel>
      </rss>
      <?php
      }

    • Artem Feb 14,2025 AT 5:04AM - Posted 1 month ago - #378766

      Hello,

      Date/Time:

      https://docs.myeventon.com/documentations/event-post-meta-variables/

      evcal_srow UNIX event start value

      evcal_erow UNIX event end value

      Please take a look at how you retrieve locations:

      https://docs.myeventon.com/documentations/taxonomies-eventon/

      The same with speakers, just use event_speaker $taxonomy.

    • Tom Carroll Feb 16,2025 AT 5:21PM - Posted 1 month ago - #378856

      Brilliant, thanks! That’s what I was looking for.

    • Artem Feb 17,2025 AT 4:29AM - Posted 1 month ago - #378869

      We are glad your issue is resolved, if you have any further questions or concerns please create a new ticket. If you have a moment, we would greatly appreciate if you could kindly leave us a review at Codecanyon. By going to your account > Downloads. We are very grateful for your kind review!

You must login to reply to this ticket

HelpDesk

Welcome to EventON helpdesk.

EventON is the #1 Best selling event calendar plugin for WordPress websites in envato marketplace.

Checkout EventON