Change Post Order to Order by Last Modified Posts

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', 'order_posts_by_modified_date' );

function order_posts_by_modified_date( $query ) {
	if ( $query->is_home() && $query->is_main_query() ) {
		$query->set( 'orderby', 'modified' );
		$query->set( 'order', 'DESC' );
	}
}