0
votes

I'm using fetch_feed() to fetch the google calendar feeds in wordpress. Here's my code:

            <?php include_once(ABSPATH . WPINC . '/feed.php'); 

                  $feed = fetch_feed('http://www.google.com/calendar/feeds/[email protected]/public/full');

                  $limit = $feed->get_item_quantity(20);

                  $items = $feed->get_items(0, $limit);

                if (!$items) {

                    echo "problem";

                } else {

                    // everything's cool

                    foreach ($items as $item) { ?>

                        <a class="event-link" href="<?php echo $item->get_permalink(); ?>">
                          <div class="sidebar-post resource-box">
                            <p class="date"><span>Date:</span> <?php echo $item->get_date('F j, Y'); ?></p>
                            <h5><span>Title: </span><?php echo $item->get_title(); ?></h5>
                            <p><span>Description:</span> <?php echo $item->get_content(); ?></p>
                        </div>
                      </a>
                        <br>

                <?php } 

                } ?>

        <?php } ?>

But the problem is it is not showing up the latest feeds. This is the feed url of this calendar. https://www.google.com/calendar/embed?title=NAMI%20St.%20Tammany%20Events&mode=AGENDA&height=600&wkst=1&bgcolor=%23FFFFFF&src=namisttammany%40gmail.com&color=%232952A3&ctz=America%2FChicago

1

1 Answers

0
votes

I got an amazing plugin for achieving this. Go through this link - http://wp-event-organiser.com/

Here are the steps.

  1. Download the ics file using this url - www.google.com/calendar/ical/[email protected]/public/basic.ics‎

  2. Export the ics file using wp event organizer plugin.

  3. The event organizer parses the ics file into custom posts named events(which was created automatically when the ics file imported)

  4. Refer this documentation to display the custom fields like date, location - http://codex.wp-event-organiser.com/

That's it!