Works perfect, I added another taxonomy “prumysl” to condition too:
function custom_reference_order($query){
if( !is_admin() && ( is_post_type_archive(‘reference’) || is_tax(‘odberatel’) || is_tax(‘prumysl’) ) && empty( $query->query_vars[‘suppress_filters’] ) ){
$query->query_vars[‘meta_key’] = ‘ref-rok’;
$query->query_vars[‘orderby’] = ‘meta_value’;
$query->query_vars[‘order’] = ‘DESC’;
}
return $query;
}
add_filter( ‘pre_get_posts’, ‘custom_reference_order’ );
Thanx a lot David for Your great work and help as always.