Home›Toolset Professional Support›[Resolved] How to output repeatable field groups on the front-end in the same order as the backend?
[Resolved] How to output repeatable field groups on the front-end in the same order as the backend?
This thread is resolved. Here is a description of the problem and solution.
Problem:
In the backend post edit screens repeatable field groups can be re-ordered with drag and drop. How can they be output on the front-end in the same order?
Solution:
The order is stored as a custom field "toolset-post-sortorder", and so the View settings for ordering need to order by that custom field.
This support ticket is created 5 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Hi
Think there's a bug with repeating field blocks. I've created a simple 'page builder' for a client with various content block types, as repeatable field groups. However, when these are re-ordered in the back-end, the changes aren't reflected on the front-end. The site is still in development so can't share a link but screengrabs are attached. The "Quality" panel should be appearing above the "Download" one. I've updated to 3.2.7 and the issue is still there.
The sort order is stored as post meta with a key of toolset-post-sortorder, so that's what you need to set in your View that outputs the fields on the front end.
According to the documentation for toolset_get_related_posts you can include 'meta_value' or 'meta_value_num' as an orderby option, which looks promising, but only if you include a meta_key argument for meta_query filter, which is only partially implemented and supports only '=' or 'LIKE', but you don't want to specify what that custom field value is.
So it sounds like you cannot.
Which means a slightly tedious loop over the child posts to get the toolset-post-sortorder custom field value for each post and then sorting them into the required order, before you then loop over that sorted array to output you content as required.
Thanks. I really need to get started using Views but I'm stuck using the methods I'm comfortable with at the moment. The loop is already quite big, with conditional options for various layout types, so wrapping it in another one would be too much I think. I'll just make sure the content is added in the correct order and ignore the re-ordering function for now.