I am using this workaround to sort items based on backend order defined via drag and drop.
https://toolset.com/forums/topic/output-repeater-fields-in-their-drag-and-drop-order-in-wp-admin-edit-screen/#post-908557
In my case using the proposed workaround works for the sort order but breaks the pagination on other views, where there are archive.
add_filter( 'wpv_filter_query', function ( $query_args, $args, $view_id) {
if (( $view_id == 10448 ) || ($view_id == 10734) || ($view_id == 11714) || ($view_id == 11401) || ($view_id == 11718)) { // if displaying a View with ID equal to 374
$view_ids = array($view_id);
if (in_array($view_id, $view_ids)) {
$args = array(
'meta_key' => 'toolset-post-sortorder',
'orderby' => 'meta_value_num',
'order' => 'ASC',
);
}
}
return array_merge($query_args, $args);
}, 199, 3 );
I modified the code according to
https://toolset.com/forums/topic/wpv_filter_query/#post-306269
It seems that sorting and pagination works both.
add_filter( 'wpv_filter_query', function ( $query_args, $args, $view_id) {
if (!in_array ( $view_id , [ 10448, 10734, 11714, 11401, 11718 ] )){ // whatever views are concerned by this pb
return $query_args;
}
else {
$query_args['orderby'] = "meta_value_num";
$query_args["meta_key"] = "toolset-post-sortorder" ;
$query_args["meta_type"] = "numeric";
}
return $query_args;
}, 199, 3 );