Home›Support›English Support›[Resolved] Repeaters & Flexible content generated with acf_add_local_field() and WPML
[Resolved] Repeaters & Flexible content generated with acf_add_local_field() and WPML
This thread is resolved. Here is a description of the problem and solution.
Problem: The client reported an issue where ACF repeater and flexible content fields were not displaying on translated pages in secondary languages if the ACF Field Group is registered programmatically.
Solution: We acknowledged the issue and informed the client that our developers are working on a fix for a future update of Advanced Custom Fields Multilingual. Meanwhile, we provided two workarounds: 1. Navigate to WPML > Settings > Custom Field Translation and click on Show system fields. Search for the repeater fields that begin with an underscore (_) and set those fields to copy. 2. Alternatively, use the JSON feature of ACF instead of PHP for defining the fields. More information on this can be found at ACF Local JSON documentation.
Please note that the solution provided might be outdated or not applicable to your case. If the issue persists, we highly recommend checking the related known issues, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If you still need assistance, please open a new support ticket in the WPML support forum.
This is the technical support forum for WPML - the multilingual WordPress plugin.
Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.
I want to report a bug regarding ACF. It implies that the repeaters and flexible content fields do not display in sites powered with WPML when visiting a translated page in any secondary language. Here are the steps to reproduce it :
1) Create a simple repeater field in functions.php or other using acf_add_local_field_group().
2) Create a page and fill in the repeater with content. Publish and translate the page in a secondary language with WPML.
3) On the page, var_dump() the fields with get_field(). You can try using the field name and then the field key.
You will notice that the fields are returned correctly in the primary language, but not in the secondary language. From my testing, the issue also extends to Flexible Content.
I noticed that, in the wp_postmeta table, there are missing entries for the post in the secondary language. Namely, all the entries that start with a underscore "_" followed by the field name that are involved in the repeater/flexible content created earlier are missing.
As WPML is advertised as fully compatible with ACF, I would hope that you could look into this issue. I hope this provides enough insight regarding the issue. If you need any more details, please let me know and I will provide any additional detail required.
Thank you very much for your time and consideration.
I have a changed the translation preferences for my repeaters and flexible content from 1 to 3 but I don't notice a change in behavior, and the issue is still present.
My small-scale example looks as such currently. Is there another step I could try?
Alright, it is done. I've created a test post that has my test repeater filled and translated. You will see that doing a var_dump() of the repeater field works as expected in the original language, but in the translated language it only returns the count of items from the repeater.
And as I said earlier, it probably has to do that there are some entries missing in the post_meta of the translated post...