Make WordPress Core

Opened 8 years ago

Last modified 13 months ago

#21872 new defect (bug)

RSS Widget, and all of fetch_feed() I believe, forces its own feed order of Post Date DESC

Reported by: madtownlems Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: External Libraries Keywords: needs-patch needs-unit-tests
Focuses: Cc:


My events management plugin wanted to provide Upcoming Events via RSS. I wrote a pre_get_posts filter to modify the order and orderby of the event's feed to be Ascending based on a the event's start date, and it was good.

Good, however, for only as long as you don't subscribe to the feed using WordPress (whether it be the event site or one on a totally different network). WordPress, upon fetching the feed, always re-sorts the posts according to the post date. Subscribing with something like iGoogle, will show me my upcoming events in the order that I've coded.

Is this an intentional design decision? It feels to me that the generating site should be responsible for the order of the feed, and WordPress should respect the generating site's wishes and present the feeds in the order it is given.

Change History (6)

#1 @nacin
8 years ago

This is actually SimplePie. Having a feed out of order by post date is a bit weird, but long ago I found if you have multiple items with the same date, SimplePie might rearrange them, which produces unexpected results. Unsure if that affects 1.3 or even 1.2 SimplePie.

There's a way to tell SimplePie to ignore sorting. I don't remember what it is, but you can use the wp_feed_options hook, which passes the SimplePie object along with the URL as context.

#2 @nacin
8 years ago

It's $simplepie->enable_order_by_date( false );

#3 @MadtownLems
8 years ago

There's a way to tell SimplePie to ignore sorting

Yes, but as far as I can tell, only on output. Let's say I have Site A with my calendar on it.

I'd like any other site to be able to subscribe to upcoming events via RSS.

I still can't do that with $simplepie->enable_order_by_date( false ) because that is code that would need to be run on the _displaying_ site, rather than the site generating the feed.

In order for Site B to display Site A's events in the desired order using this wp_feed_options code, Site B would need the code on it, while the plugin is from Site A (the site generating the feed).

#4 @c3mdigital
7 years ago

  • Component changed from General to External Libraries

#5 @wonderboymusic
6 years ago

  • Keywords needs-patch added

#6 @chriscct7
5 years ago

  • Keywords needs-unit-tests added
Note: See TracTickets for help on using tickets.