I have quite a complicated layout, which includes numerous groups inside Custom field group. Let’s say:
Custom field group
These groups do appear a certain pages as expected. Thing is that I want the order of this groups to be changed, when creating a page, the same way you can reorder fields by drag-and-drop, when creating field groups. For example on the page “A” I want the default order of 1-2-3, on page “B” I want it to be 3-2-1, and on page “C” — 2-1-3 etc.
Isi it possible to achieve or is there workaround to get this kind of flexible layout? Thank you!
There is a filter in ACF that is not documented
$field_group = apply_filters('acf/get_field_group', $field_group);
I can’t give you all the details of how this might be done, but it might be possible to alter the order of the field groups at this point.
1) You’d need to see what field groups is being loaded.
2) Then you’d need to see page it is being loaded for, not sure this can be done or how.
Based on this you might be able to alter the sort order of each field group.
Like I said, I’m not sure this can actually be done, but if it can be this would be the only way. Also, note that if the editor has already saved a page with these groups that WP will alter the order of the groups to the same as the last time they saved and WP keeps track of this drag-able sort order per post type, so even if you do succeed in changing the order in ACF, it may do you no good when dealing with posts of the same post type. To overcome that you’d need to figure out how to override WP’s sort order.
Hi, I’m not sure if this functionality was available at that time (three years ago), but now I would use Flexible content feature to solve this problem. Note, that it’s a part of PRO version. Basically with flexible content you could build structures of any complexity and arrange fields the way you want.
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
Sorry for the issues with ACF's API SSL certificate this morning. We've resolved it and your activations and downloads should be back to normal again. Thanks! ^LG— Advanced Custom Fields (@wp_acf) November 2, 2022
© 2022 Advanced Custom Fields.