• Resolved swcomm

    (@swcomm)


    Hi – I have a custom feed that orders posts by a custom date field via a pre get posts query, rather than the post publish date. The feed URL I’m importing does sort the posts correctly. But I can’t get those posts to display in the order I need them when importing via your plugin’s widget and it seems to be overriding the order in my query, as posts always display in publish date order. Using date=false, and have tried both no orderby clause in the widget, as well as orderby=”” (in an attempt to fool it into using no orderby) Thanks in advance for advice.

Viewing 5 replies - 1 through 5 (of 5 total)
  • I had the same problem.

    FYI, I figured out what is going on here, the plugin is using the feed functions of wordpress, and apparently the sort by date is default behavior, even if not specified.

    if ( !is_wp_error( $rss ) ) {
        if ($orderby == 'date' || $orderby == 'date_reverse') {
        $rss->enable_order_by_date(false);
        }

    This is a hack, but it works. Line 61, $rss->enable_order_by_date(false), instead of true. The next update for the plugin should specify:

    $rss->enable_order_by_date(false)

    before it gets into the logic of setting it to true. This way, the output matches the rss.xml feed as displayed, instead of using the original post date.

    Where I specifically had a problem was where a feed item was originally dated in March, but updated last month with new info and was now at the top of the rss feed (the publish date remained as March).

    Once I changed the true to false, my local feed matched the remote feed perfectly.

    Recommended future plugin code change:

    $rss = fetch_feed( $urls );
        
    $rss->enable_order_by_date(false); #<--set default behavior.
        
    remove_filter( 'wp_feed_cache_transient_lifetime', 'wp_rss_retriever_cache' );
    
    if ( !is_wp_error( $rss ) ) {
      if ($orderby == 'date' || $orderby == 'date_reverse') {
          $rss->enable_order_by_date(true);
        }

    Great plugin, five stars!!!

    • This reply was modified 5 years, 9 months ago by perltechs.
    • This reply was modified 5 years, 9 months ago by perltechs.
    • This reply was modified 5 years, 9 months ago by perltechs.
    Thread Starter swcomm

    (@swcomm)

    Hi – that’s funny, I did kind of the same thing. Hacked enable_order_by_date to false in the plugin. Works beautifully. Yes, I agree, it’s a great plugin but needs this one small modification to enable alternate date sorting method.

    Plugin Author Travis

    (@tjtaylor)

    Thanks for your feedback! I’ll be shipping this change with the next version.

    Hi Travis, this is exactly my problem. I’m using an RSS feed for which I need the posts to be in the original order. But when I use your plugin it sorts them. Can you please update the plugin so it’s possible to leave the feed in the original order? Thanks

    @perltechs , I changed line 61 in the plugin editor to $rss->enable_order_by_date(false) and clicked “Update file” but the order of the posts is still sorted. Is there something else that I need to do?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Orderby’ is closed to new replies.