How to order posts by modified date without using ‘query_posts’?

You haven’t specified where you want this alteration to apply to so I’ve applied it to just the home page. You may alter to fit where this filter applies to:

<?php
function wpse10691_alter_query( $query )
{
    if ( $query->is_main_query() && ( $query->is_home() || $query->is_search() || $query->is_archive() )  )
    {
        $query->set( 'orderby', 'modified' );
        $query->set( 'order', 'desc' );
    }
}
add_action( 'pre_get_posts', 'wpse10691_alter_query' );
?>

Place code into theme functions.php or package into a plugin.

Leave a Comment