I'm using wordpress with a frontend framework, which means I need to give it json data instead of using wordpress functions inside a .php template file.
While using ACF with WPML I faced two problems : `get_fields($translation_id)` returns false, which means I have to get all fields keys and use get_field($key, $translation_id) on them to get the data (which is a pain honestly.)
This workaround works well for every field EXCEPT for the medias.
As you can see in the attached screenshot, for each fields, get_field() returns the expected field translations AND the field original values are not translated.
In this exemple, 65 is the ID of the original Image, while 66 is the translated one (see second screenshot)
In the case of Medias, Original fields are translated AND get_field() doesn't trigger the 'acf/format_value/type=image' filter, which make it impossible to format the value.
WPML should be consistant across each translation types :
- Medias should be translated like a regular post. (original content must be accessible from a translation query loop), In my exemple, get_field with the translation ID should return Image with ID 66 not 65, and get_field with the original ID should return Image with ID 65.
- ACF fields must trigger ACF lifecycle hooks (using get_field on an image should trigger acf/format_value/type=image filters, etc.). In the exemple, get_field('centerImage', $translation_id) should return the formated values, not the raw ID. Like it is done in the original language.
- get_fields($translation_id) should return every translated field, instead of forcing us to loop over keys and get_field($key, $translation_id)
Unfortunately we do not provide support for custom coding. However, WPML offers filters and action hooks that can be used in your WordPress theme or plugin to provide correct multilingual support. Browse following resources for more information: