I think you simply have to replace:
$feed->enable_order_by_date(false);
with
$rss->enable_order_by_date(false);
to disable the descending date ordering.
In the case of a feed error, the fetch_feed()
function returns an instance of the \WP_Error
class. Otherwise the output is an instance of the \SimplePie
class and this class contains the enable_order_by_date
() public method.
So you should use it like this:
// Fetch the feed:
$rss = fetch_feed( $feed_url );
// Make sure we don't have and WP_Error instance:
if ( ! is_wp_error( $rss ) )
{
// Disable the date ordering:
$rss->enable_order_by_date( false );
// ... etc ...
}
where we (implicitly) make sure we have an instance of the \SimplePie
class.