WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: The Events Calendar] Start date on rss feed? (11 posts)

  1. babyewok
    Member
    Posted 2 years ago #

    I really want to be able to show a list of upcoming events onthe homepage (outside of WordPress). I can use the rss feed to show the post and the date it was posted, but I want to show the event start date, not the post date. I have scoured Google and the forums and it seems that a few people want this, but no solution has been offered.

    I have looked into customising the wordpress feed (read the codex), but I have no idea where to start as nothign seems to relate to adding extra info like this to the feed.

    Please help - someone must have figured this one out!

  2. babyewok
    Member
    Posted 2 years ago #

    I should also say I am using simplepie to display the rss on the homepage

  3. babyewok
    Member
    Posted 2 years ago #

    OK, how about not so much replacing get_date but showing the event start date as a custom field (I assume that is how it is set up) on the rss and output to simplepie (would I also need to make a change to class-simplepie.php or is it already set up to handle custom fields?).

    I'm not really bothered about people following the rss and being able to see the start date - I just need to get it working so that I can output the 5 upcoming events on the homepage with their start dates.

    Lots of people use this plugin - surely someone else has been able to figure this out - HELP!

    Edit - unless class-simplepie has nothign to do with dealing with feeds outside of WordPress in which case I belive it is down to just editing the feed itself...still stuck though!

  4. roblagatta
    Modern Tribe Support
    Posted 2 years ago #

    Hey there babyewok. Thanks for the notes here, and for the update on where in the process you are. It seems like - if I understand what you're trying to do here correctly - you could accomplish this through use of template tags. We've documented those at http://tri.be/support/documentation and it should give you what you need.

    Want to review that and let me know?

  5. babyewok
    Member
    Posted 2 years ago #

    Hi - surely the template tags won't work outside of WordPress? Or do you mean to use them in the rss file itself?

  6. babyewok
    Member
    Posted 2 years ago #

    Hmm, I have found this on the simplepie site: http://www.simplepie.org/wiki/tutorial/grab_custom_tags_or_attributes

    It informs you how to grab a custom tag and then use that tag to order the items. Could someone tell me how I could modify this to list events form the events manager?

    I am using a custom field plugin that adds custom fields to the rss using a tag called <custom_fields>.

    I just don't know how to then pull the _EventStartDate from this tag and use it in a similar way to this demo. Any ideas?

  7. babyewok
    Member
    Posted 2 years ago #

    OK, scrapping the plugin and editing feed-rss2.php directly, adding:

    <?php
      $key="_EventStartDate";
      if ( get_post_meta($post->ID, $key, true) ): ?>
        <custom><?php echo get_post_meta($post->ID, $key, true); ?></custom>
      <?php endif;
    ?>

    to the <item> tag and then using Simple Pie to output the folowign loop:

    <?php foreach ($feed->get_items($start,$length) as $item) {
    $when = $item->get_item_tags('', 'custom');
    
    	?>
    <h4><a href="<?php echo $item->get_permalink(); ?>"><?php echo substr($item->get_title(), 0, 36) . '...'; ?></a></h4>
    <?php  print_r($when)  ?>
    <p><?php echo substr($item->get_description(), 0, 160) . '...'; ?></p>
    <?php } ?>

    I get the following output, so I know I have targeted the Event Start Date:

    --------------
    New event...
    Array ( [0] => Array ( [data] => 2012-04-20 00:00:00 [attribs] => Array ( ) [xml_base] => [xml_base_explicit] => [xml_lang] => ) )

    Blah blah…
    -------------

    Now I just need to figure out how to edit the SimplePie demo I linked to previously to use that date....any ideas?

  8. babyewok
    Member
    Posted 2 years ago #

    I should point out that I was only using print_r($when) to make sure I had correctly targeted the _EventSartDate custom field and see what was spat out.

    I plan on using the loop as set out in the demo

  9. babyewok
    Member
    Posted 2 years ago #

    I think it is specifically this line that I am stuck on:
    $date = $when[0]['attribs'][''][''];

    as when I put:
    $date = '2012-04-20 00:00:00'

    as a test it seems to output nicely. I have managed so far by trial and error but really have no idea what I am doing so if someone can help me with the last pice of the puzzle, I would be grateful!

  10. babyewok
    Member
    Posted 2 years ago #

    Aha! Changed the rss to this:
    <custom date='<?php echo get_post_meta($post->ID, $key, true); ?>'></custom>

    Then the simplepie to this:
    $date = $when[0]['attribs']['']['date'];

    Success! Woohooo!

  11. roblagatta
    Modern Tribe Support
    Posted 2 years ago #

    Ah, glad to hear you got this resolved on your own (and my apologies we didn't see the thread during the time when you were having problems). If you need assistance down the road please do let us know.

Topic Closed

This topic has been closed to new replies.

About this Topic