Hello,
i do not know how i can sort by seondary field in the sorting controls.
All results should always by first sort by "field-wpcf-paket" and secondary sort by customer select.
At the moment whe i change the sorting so the sort by field-wpcf-paket is not set.
hidden link
Please help.
Nice regards
Markus
Hi, I don't think it's possible to allow Users to control a secondary sorting method in a View's filters, but you may be able to do something like this with the wpv_filter_query and some custom code. We have documentation for this filter and some examples available here:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query
You could check the User's selected Query, then manipulate the final Query to insert the Paket order as primary, then the User selection as secondary. It's fairly complex when you have to account for order by post title and/or meta values, but there is a similar example here: https://wordpress.stackexchange.com/questions/65769/multiple-orderby-values-in-wp-query
Hi Christian,
can you please give me an example how i can set the order by user as secondary sorting and set the primary sorting always to paket?
If it is extra work for you so you can create me an offer for that work.
The closest example of this type of query I can find is here: https://wordpress.stackexchange.com/questions/65769/multiple-orderby-values-in-wp-query/65772#65772
Here's an example showing how you can modify a query, including the orderby clause, with the wpv_filter_query API:
add_filter( 'wpv_filter_query', 'filter_fieldslug_9876', 10, 3 );
function filter_fieldslug_9876 ( $query, $view_settings, $view_id ) {
$views = array( 1234 );
if( in_array( $view_id, $views) ) {
$args = array(
'relation' => 'AND',
array(
'key' => 'wpcf-fieldslug',
'value' => 9876,
'compare' => '=',
'type' => 'numeric'
)
);
// add these arguments to your meta query
$query['meta_query'] = isset($query['meta_query']) ? $query['meta_query'] : [];
$query['meta_query'][] = $args;
$query['orderby'] = 'wpcf-fieldslug menu-order';
}
return $query;
}
I'm happy to help troubleshoot custom code you have written related to our APIs, but we don't write that level of customization for you here in the support forums. If you're interested in getting professional assistance, you may be able to connect with a skilled developer in our Contractors portal: https://toolset.com/contractors
ok i will contact the contractors for help.
Is there a possibility that this feauture will be implemented in future releases of Toolset?
I think that is an important point the secondary sorting.
Nice regards
Markus