is there a way to control the position of a field added with acf_add_local_field?
'key' => 'field_5',
'label' => 'Sub Title',
'name' => 'sub_title',
'type' => 'text',
'parent' => 'group_1',
// ? 'position' => 2.1
for example: if group_1 already contains field_1, field_2, field_3, field_4, I would like to add field_5 between field_2 and field_3
something like ‘insert_after’ => ‘field_2’ would be awesome, but a numeric position would do the job as well.
( ps. ACF is absolutely great )
I’ve looked into this and the only way to add a new field to an already registered group is to add it at the end.
Are you registering the entire field group? If you are the best solution would be to build an array or fields in the order you need them and then loop through the array to register them. You could then build your own function to insert a field into the middle of your array where you want it to go.
Too bad that there is no native way to do this. I will proceed as you suggested. I guess my original question is a feature request then 🙂
Thanks for your help!
I’ve marked this thread for the developer. Maybe he’ll decide it’s a good idea and add it if he finds time to read this topic.
I think you could use the ‘acf/get_fields’ filter to change the order before they get rendered