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.
Opens WPIDE on
Code
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 add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.