This thread is resolved. Here is a description of the problem and solution.
Problem:
The client is trying to translate Advanced Custom Fields (ACF) option pages using WPML and encounters issues with retrieving translated values using WordPress's native functions. They find that the translated values only appear when manually including the language code in the option key.
Solution:
1. To retrieve translated ACF option values, use the following ACF-specific functions after ensuring you have backed up your site:
//Retrieve a field $variable = get_field('field_name', 'option'); //Display a field <p><?php the_field('field_name', 'option'); ?></p>
For more details, refer to the ACF documentation on getting values from an options page and WPML's guide on translating ACF options pages.
2. If you prefer using String Translation for ACF Option Page values, follow these steps:
- Register the ACF Option Page values in String Translation using the
wpml_register_single_string
hook.
- Translate the registered strings in WPML String Translation.
- Display the translated strings using the
wpml_translate_single_string
hook.
For further guidance, check the documentation on wpml_register_single_string and wpml_translate_single_string.
If this solution does not resolve your issue or seems outdated, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If needed, please open a new support ticket at 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.
This topic contains 5 replies, has 0 voices.
Last updated by 1 month, 1 week ago.
Assisted by: Bigul.