I followed https://toolset.com/documentation/getting-started-with-toolset/creating-and-displaying-repeatable-field-groups/#displaying-repeatable-field-groups
Screenshot of my View's settings: hidden link
I'm getting the repeating fields to output but they're in the order I created them, not their drag-and-drop order. In other words, sorting by "Post date" in Ascending/Descending works as expected, but this doesn't match the drag-and-drop order.
Which "Order by" option do I need to select? Suggestion: Doesn't the View know when I'm rendering repeating fields and therefore shouldn't the *View ordering* be irrelevant and they *always* display in drag-and-drop order regardless of the View's "order by" setting? Or should there be an "order by drag-and-drop" option?
Hi Clifford, I see what you're describing. Let me reach out to my developers to see if this is a bug, an oversight, or if the ordering functionality is expected to be included in a future release. For now, I can offer the following custom code as a temporary solution. Add the code in your functions.php file to order the field groups in the View by the sort order you define in wp-admin:
add_filter( 'wpv_filter_query', 'order_rfg_by_wp_admin_sort', 199, 3 );
function order_rfg_by_wp_admin_sort( $query_args, $views_settings, $view_id) {
$view_ids = array( 12345 );
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);
}
Replace 12345 with the numeric ID of the View. Let me know if this does not apply the correct sorting.
Thanks. That confirms I should use this sorting: hidden link
However, it feels like the documentation both on your site and in-context (that blue info box) are missing that the "Field - toolset-post-sortorder = Ascending = As a native custom field" (or "As a number") is the only way to get them to appear in their drag-and-drop order.
That field name should be selected by default or right at the top to easily select it / suggest selecting it.
And "Descending" being the default option makes them in reverse order, which doesn't make sense either. I appreciate the flexibility to be able to display in reverse order, but it's confusing UX to just get the expected display order.
And "As a string" just doesn't work so the whole drop-down shouldn't even display (extra confusion) if toolset-post-sortorder is the selected ordering field.
Hope all that feedback is easy enough to understand. Thanks!
Okay yes, I can confirm that the Field - toolset-post-sortorder option will order by the RFG order of appearance in wp-admin. As far as the default order selection, I will refer this ticket to Beda, who handles feature requests. He will evaluate your request to improve the usability of the RFG feature and respond to you soon.
Makes sense, I added the request.
I saw a version update come through but the changelog was vague, and I couldn't find any changelog on your site. Was this bug fixed in this latest update?
Hello
I tried the code
---------------------
add_filter( 'wpv_filter_query', 'order_rfg_by_wp_admin_sort', 199, 3 );
function order_rfg_by_wp_admin_sort( $query_args, $views_settings, $view_id) {
$view_ids = array(369);
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);
}
----------------------------------
It does work on the view '369', but it breaks all other views 'No items found' Can you please tell me how to make it work only for the views I select?
Thanks
miguelG-5, you must define the $args array outside the conditional like this:
add_filter( 'wpv_filter_query', 'order_rfg_by_wp_admin_sort', 199, 3 );
function order_rfg_by_wp_admin_sort( $query_args, $views_settings, $view_id) {
$view_ids = array(369);
$args = array();
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);
}
Please open a separate ticket if you continue to experience problems.
Thank you Christian, this time it works well
+1 for @Clifford for reporting this; I was having same issue. I see that selecting that "Field - toolset-post-sortorder : Asc : Number" works, but that's certainly not very intuitive.
I second the idea that it be renamed something more obvious (like "Repeating Group UI Order" or whatever) and not offer the string/number option at all; and default to ASC (as in the UI)