I am trying to get category pages to sort by date, for some reason it still sorts by title. Is there a function I should override? This is the code I am using.
add_action( 'pre_get_posts', 'my_change_sort_order');
function my_change_sort_order($query){
if($query->is_archive() || $query->is_category()):
//If you wanted it for the archive of a custom post type use: is_post_type_archive( $post_type )
//Set the order ASC or DESC
$query->set( 'order', 'DESC' );
//Set the orderby
$query->set( 'orderby', 'post_date' );
return;
endif;
};