WordPress.org

Make WordPress Core

Opened 19 months ago

Last modified 8 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: Awaiting Review Priority: normal
Severity: normal Version:
Component: External Libraries Keywords:
Focuses: Cc:

Description

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 (4)

comment:1 nacin19 months 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.

comment:2 nacin19 months ago

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

comment:3 MadtownLems19 months 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).

comment:4 c3mdigital8 months ago

  • Component changed from General to External Libraries
Note: See TracTickets for help on using tickets.