Make WordPress Core

Opened 12 years ago

Closed 4 years ago

#21872 closed defect (bug) (wontfix)

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

Reported by: madtownlems's profile madtownlems Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: External Libraries Keywords:
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 (7)

#1 @nacin
12 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
12 years ago

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

#3 @MadtownLems
12 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
11 years ago

  • Component changed from General to External Libraries

#5 @wonderboymusic
10 years ago

  • Keywords needs-patch added

#6 @chriscct7
9 years ago

  • Keywords needs-unit-tests added

#7 @desrosj
4 years ago

  • Keywords needs-patch needs-unit-tests removed
  • Resolution set to wontfix
  • Status changed from new to closed

Hi @madtownlems,

Sorry that this ticket fell through the cracks for so long.

modify the order and orderby of the event's feed to be Ascending based on a the event's start date

Based on this, it seems that you are altering the post order in feeds using a post meta field's value. SimplePie will always sort by the appropriate date field based on the feed format unless ordering by date is disabled as mentioned above, (but that leads to the issues you described).

You could use a filter to change the publish date to the event start date in your event feeds. But this is documented in the RSS specification as potentially problematic, as aggregators may choose to not display items with a date in the future.

As far as I know, there's nothing that can be done here to reliably control the ordering of posts externally. If the RSS/Atom specs are amended to include a property that could be used for events, the SimplePie library would most likely need to be updated, and adding this property to feed items is probably plugin territory anyway. For those reason I am going to close this out.

Note: See TracTickets for help on using tickets.