Yes, it’s possible. There are two requirements:
1. You need a child theme.
2. You need to know your category ID or the category slug. To find out the category ID go to your categories and hover over the edit category link. Watch the href displayed for the value of tag_ID.
Now, add this code in functions.php of your child theme and replace {$cat_ID_or_slug} with either category ID or the category slug:
function sort_category( $query ) {
if ( $query->is_category('{$cat_ID_or_slug}')
&& $query->is_main_query()
&& ! $query->is_admin() ) {
$query->set( 'orderby', 'modified' );
}
}
add_action( 'pre_get_posts', 'sort_category' );
I can’t test it right now. Get back to me if it doesn’t work. It should work, afaik is_category() is inside query.php, so it’s usable with pre_get_posts.
I’ve tested the code above and is_category() conditional doesn’t seem to work during pre_get_posts. Only $query->is_category works, if you’re on any category page. I tried a few more methods and this one seems to work:
add_action('wp_head', 'sort_category');
function sort_category() {
global $query_string;
if ( is_category('category-slug')
&& is_main_query()
&& ! is_admin() )
$posts = query_posts( $query_string . '&orderby=modified' );
}
Note: Change category-slug above with the actual category slug.
Another note: The first code is supposed to work, too, I don’t know why it didn’t in my tests. It might have to do with a bug on using is_category(tag_ID) on $wp_query, according to comments in this thread.
So basically it needs a check on whether the category with that id actually exists:
function sort_category( $query ) {
if ( $query->is_main_query()
&& term_exists(314,'category')
&& $query->is_category(314)
&& ! is_admin() ) {
$query->set( 'orderby', 'modified' );
}
}
add_action( 'pre_get_posts', 'sort_category' );
where 314 needs to be replaced with the actual category ID.