• One of our client’s has multiple websites that need to display an RSS feed from a calendar with the soonest events showing first. The events from the feed do show when using the shortcode, but they show in the incorrect order. The events farthest away show first. Is it possible to flip the order in which the feed items show?

    Thanks for the help.

    https://www.ads-software.com/plugins/wp-rss-aggregator/

Viewing 4 replies - 16 through 19 (of 19 total)
  • If we’re still talking about the same calendar feed for all these questions, then I’d try setting the “limit feed items by age” to 1 day like you said. Definitely not 0 days since that’ll be understood as being no limit. Also, for that feed, feed processing interval will probably end up being irrelevant and you can just refresh how often you like.

    Unfortunately this is one of those things that I can’t test precisely, but based on the code it should work.

    Thread Starter Jonathan Goldford

    (@jg-visual)

    Awesome. Thanks a ton for the help. This should keep us from showing old events that have already passed.

    The other issue we were concerned about was if someone updates the title of an event, which happens regularly. This isn’t then reflected in the stored feed item. This might also be an issue if the date is updated as well. To deal with this we added the following code in functions.php:


    <?php
    add_action( 'wprss_fetch_all_feeds_hook', 'wi_delete_all_feed_items', 1 ); //Priority 1 so feed items are all deleted before they're fetched.
    function wi_delete_all_feed_items(){
    $args = array(
    'post_type' => 'wprss_feed_item',
    'post_status' => array( 'publish', 'future' ),
    'cache_results' => false, // Disable caching, used for one-off queries
    'fields' => 'ids', // Returns post IDs only
    'posts_per_page' => -1,
    );
    $feed_item_ids = get_posts( $args );
    foreach( $feed_item_ids as $feed_item_id ) {
    $purge = wp_delete_post( $feed_item_id, true ); // delete the feed item, skipping trash
    }
    wp_reset_postdata();
    wprss_log( sprintf( 'All feed items deleted: %1$d', count($feed_item_ids) ), __FUNCTION__, WPRSS_LOG_LEVEL_INFO );
    }
    ?>

    We adapted this from a function within the plugin and it deletes all of the feed items before every fetch, ensuring the events are always accurate.

    Aside from the concern of running this too frequently, do you see any issues with this approach? I think we’re almost there so thanks again.

    Jonathan

    Yeah, we currently don’t have a way to update the feed items we’ve already imported.

    Your approach looks like it’ll work, though you point out the obvious flaws in it. Additionally, you’re deleting /every/ feed item that’s ever been imported when you could just be deleting the feed items for this feed source in particular. You could instead hook into the wprss_fetch_single_feed_hook which is called iteratively in the wprss_fetch_insert_all_feed_items function. That would let your refine your get_posts() query to speed up the entire query/delete/insertion procedure.

    Thread Starter Jonathan Goldford

    (@jg-visual)

    Great suggestion. I think we’ll leave it as is since every site that pulls a feed only has one, but this is another awesome resource.

    Thanks a ton for the help. I really appreciate the great support and I made sure to leave a positive plugin review for you all.

    I’ll go ahead and mark this resolved.

Viewing 4 replies - 16 through 19 (of 19 total)
  • The topic ‘Change Order of RSS Feed?’ is closed to new replies.