Last active
May 8, 2023 14:17
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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