Change Post Order to Last Modification Date
If you want to list the posts in your blog view ordered by last modified date (in descending order), you can use this snippet:
add_action( 'pre_get_posts', function ( $query ) {
if ( $query->is_home() && $query->is_main_query() ) {
$query->set( 'orderby', 'modified' );
$query->set( 'order', 'DESC' );
}
} );
Related Posts
- Change Post Order to Order by Last Modified Posts
- Increase Upload Size when Using VestaCP
- Shortcode for Listing the Recent Posts or CPTs
- SQL: Delete All Rows Except Last X
- Query Posts Where Custom Field is Set / NOT NULL
- Query Posts Where Custom Field is NULL
- Shortcode Showing the Latest Posts Using Timber
- Install Umami Analytics with Let's Encrypt HTTPS