Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save koskinenaa/3a1978d880fa0232ef5901ed0c19ca84 to your computer and use it in GitHub Desktop.

Select an option

Save koskinenaa/3a1978d880fa0232ef5901ed0c19ca84 to your computer and use it in GitHub Desktop.
RSS feeds read by WordPress are ordered by date by default. Use `wp_feed_options` action to disable date ordering and consume the items in their own order.
<?php
// E.g. fetch_feed('https://www.example.com/some-feed');
add_action( 'wp_feed_options', 'my_feed_options', 10, 2 );
function my_feed_options( SimplePie $feed, $url ): void {
$my_feed = 'https://www.example.com/some-feed';
if ( ! is_string($url) || $my_feed !== $url ) {
return;
}
// https://simplepie.org/wiki/reference/simplepie/enable_order_by_date
$feed->enable_order_by_date(false);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment