# Order Feeds by Last Updated Date

> Lists feed items by the date they were last updated instead of the publish date, so readers see refreshed articles again.

- Type: PHP
- Runs: Run everywhere
- Category: [RSS Feeds](https://wpide.com/library/category/rss/)
- Tags: rss, order, modified-date
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/order-feeds-by-last-modified/

## Code

```php
add_action( 'pre_get_posts', function ( $query ) {
    if ( ! is_admin() && $query->is_main_query() && $query->is_feed() && ! $query->is_comment_feed() ) {
        $query->set( 'orderby', 'modified' );
        $query->set( 'order', 'DESC' );
    }
} );
```

## Notes

Some readers show an updated post as a new item. Use it if you regularly refresh older content.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Order Feeds by Last Updated Date" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
