Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter MalMac

    (@malmac)

    I have tried the following:
    —-

    add_filter( ‘wprss_display_feed_items_query’, ‘wprss_reverse_order’, 10, 2 );

    function wprss_reverse_order( $args, $settings ) {
    $args[‘order’] = ‘DESC’; // newest first
    return $args;
    }

    Not currently working though

    Plugin Support Hendra Setiawan

    (@hendcorp)

    Hi @malmac

    What you have at /qnfeed/ is the plugin’s Custom Feed, and right now it lists imported items in ascending date order, oldest first. There is no option under Aggregator > Settings > Custom Feed to change that yet, and the sort order of a Display does not apply to the Custom Feed, so changing it there will not help.

    One thing worth knowing: when a limit is set (yours is 100), that same ascending order also decides which items get picked. So the feed holds the 100 oldest imported items rather than the 100 newest. Yours currently runs from January 2021 to March 2026. If you have more than 100 imported items on the site, anything newer than that is not in the feed at all.

    The snippet below puts the newest items first and makes the feed pick up new imports. Add it to your theme’s functions.php, or through a code snippets plugin set to run on the front end. If you save it as a file in wp-content/mu-plugins instead, start the file with an opening PHP tag. We tested it on Aggregator v5.5.0, the version your feed reports.

    add_filter( 'wpra.importer.wpPosts.query.args', function ( $args ) {
        if ( is_feed( 'qnfeed' ) && empty( $args['orderby'] ) ) {
            $args['orderby'] = 'date';
            $args['order']   = 'DESC';
        }
        return $args;
    } );

    The qnfeed part is the last segment of the URL shown under Aggregator > Settings > Custom Feed, so if you ever change that URL, change it here too. Reload /qnfeed/ afterwards, and the newest item should be at the top. If your host or a caching plugin caches feeds, purge that once.

    If the snippet does not change anything on your site, please let us know here, and we will take a closer look.

    Thread Starter MalMac

    (@malmac)

    Thank you for the help, not quite working though. See following error message:

    The snippet was saved, but remains inactive due to this error: Unclosed ‘(‘ on line 2 does not match ‘}’

    About feed limits? What would you recommend for a suitable feed limit in descending order? 0 would make it unlimited?

    Thanks, MAlcolm

    Plugin Support Hendra Setiawan

    (@hendcorp)

    Hi @malmac

    That error usually means something changed in the code while it was being copied into the snippet editor. A bracket, quote, or the && may have been dropped or converted along the way, which can easily happen when copying code from an email notification rather than directly from the forum.

    I re-checked the snippet as posted on a clean Aggregator 5.5.0 site, and it is working correctly there.

    Please delete the snippet you saved and use the version below instead. It does exactly the same thing, but I’ve written it with one condition per line and removed the &&, so there is less that can go wrong when copying it.

    Please copy it directly from the code box on this page. Once pasted, also check that all quotes are plain straight quotes:

    add_filter( 'wpra.importer.wpPosts.query.args', 'qn_custom_feed_newest_first' );

    function qn_custom_feed_newest_first( $args ) {
    if ( ! is_feed( 'qnfeed' ) ) {
    return $args;
    }
    if ( ! empty( $args['orderby'] ) ) {
    return $args;
    }
    $args['orderby'] = 'date';
    $args['order'] = 'DESC';
    return $args;
    }

    If the editor still reports an error, please paste the code here exactly as it appears in your snippet editor and we can compare it.

    On the feed limit, 0 does not mean unlimited. The field does not accept 0, and if the value ends up as 0, Aggregator falls back to the default limit of 15 items.

    With the snippet active, the limit simply controls how many of the most recent items are included in the feed. As new items are imported, the oldest ones drop off.

    For a news feed, I’d normally recommend somewhere around 50 to 100 items, since feed readers generally only need the most recent entries anyway. If you want every imported item to remain in the feed, you can set the limit higher than the total number of items on the site.

    Thread Starter MalMac

    (@malmac)

    That worked. Thank you for the assistance!

    Plugin Support Hendra Setiawan

    (@hendcorp)

    You’re most welcome, Malcolm. Glad that helped! 🙂

    I’ll go ahead and mark this as resolved. If you have any other questions, feel free to open a new topic or reply here.

Viewing 6 replies - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.