Closed bohdan-jdev0 closed 4 years ago
The reason this does not work on ACF4 is that I call functions that are only available in ACF5 to get the list of field groups attached to a post and get the list of fields in each field group. These functions are acf_get_field_groups()
and acf_get_fields()
. There would need to be code added to detect the ACF version and do something different depending on that. I don't even know if this can be done in ACF4 or how.
My suggestion would be to build a filter for only the specific fields where you need this functionality. There is a document on the ACF site here https://support.advancedcustomfields.com/forums/topic/2-way-relationships/ and I have an alternate method/example here https://github.com/Hube2/acf-filters-and-functions/blob/master/acf-reciprocal-relationship.php
You can do this for ACF4. You can request the groups for ACF4 using apply_filter('acf/get_field_groups',$array) and loop over the fields-groups using acf_get_fields() to get the fieldinfo.
I use this method to support both ACF4 and ACF5 in my plugin. But only because acf4 uses save_format and acf5 uses return_format on some values.
ACF 5 was released to WP repo some time ago, this should no longer be an issue
Is it possible to adapt this plugin to version 4? Or can you help me with writing some functionality similar this?))