I am already filtering some custom posts depending on a querystring in pre_get_posts:
if( $query->is_main_query() ) {
if( is_post_type_archive( 'events' ) ) {
if ($_GET['status']) {
$retrieved_status = $_GET['status'];
$query->set('meta_key', 'event_status');
$query->set('meta_value', $retrieved_status);
}
}
}
I would then also like to sort by a different custom field, but I can't use something like below because it rewrites the meta_key:
$query->set('orderby', 'meta_value');
$query->set('meta_key', 'event_date');
$query->set('order', 'DESC');
How could I structure this to get the desired effect? Thanks!