I want to sort the view with multiple custom fields
Is there any documentation that you are following?
https://toolset.com/forums/topic/how-to-apply-custom-code-to-order-view-by-multiple-custom-fields/
i have tried to customize it for my scenario but it shows no effect.
this is how far I have come:
i have copied the following code into the fuctions.php of my theme with the id of the desired view and the custom fields
///
function tssupp_modify_orderby( $view_args, $view_settings, $view_id ){
if ( 5325 == $view_id ) { // Edit ID
$view_args['meta_query'] = array(
'relation' => 'AND',
'hersteller' => array(
'key' => 'wpcf-hersteller',
'compare' => 'EXISTS',
),
'weinart' => array(
'key' => 'wpcf-weinart',
'compare' => 'EXISTS',
),
'produktname' => array(
'key' => 'wpcf-produktname',
'compare' => 'EXISTS',
),
'jahrgang' => array(
'key' => 'wpcf-jahrgang',
'compare' => 'EXISTS',
),
);
$view_args['orderby'] = array(
'hersteller' => 'ASC',
'weinart' => 'ASC',
'produktname' => 'ASC',
'jahrgang' => 'ASC'
);
}
return $view_args;
}
add_filter( 'wpv_filter_query', 'tssupp_modify_orderby', 101, 3);
//
What is the link to your site?
cantinadelmulino.website/weine