I have a site where I am 'pulling' local events from a secondary website RSS feed. I have this working however the feed is displaying in reverse order with the local events dated later (i.e. at the end of October versus events dated for today) showing up at the top instead of the bottom.
Here is the code I am using for the feed ingest:
<?php if(function_exists('fetch_feed')) {include_once(ABSPATH . WPINC . '/feed.php'); // include the required file$feed = fetch_feed('http://sample.com.au/events/feed/'); // specify the source feed$limit = $feed->get_item_quantity(25); // specify number of items$semti = array_flip($limit);$items = $feed->get_items(0, $limit); // create an array of items}if ($limit == 0) echo '<div>The feed is unavailable.</div>';else foreach ($items as $item) : ?><p><b><a href="<?php echo esc_url( $item->get_permalink() ); ?>" target="_blank"><?php echo esc_html( $item->get_title() ); ?></a></b><?php echo esc_html( $item->get_date('| j F | g:i a') ); ?><br><?php echo sanitize_text_field( $item->get_content() ); ?></p> <?php endforeach; ?>
This works perfectly to get my remote RSS feed and display the title, date of the event and the excerpt, however the order is reverse sorted.
I tried adding filters like "sort and ksort" in the "foreach ($items $items) :" area but this did not work for me. I've racked my brains on this one and am hoping someone can help me out. I appreciate any guidance/help in advance.