Skip Navigation

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 Bigul 1 month, 1 week ago.

Assisted by: Bigul.

Author Posts
April 29, 2025 at 2:41 pm #16979792

Angeloca

Background of the issue:
I am trying to translate Advanced Custom Fields (ACF) option pages using WPML. I use WordPress’s native function to load all options: <code>$options = wp_load_alloptions();</code> and then look up my field by its key in the returned array (e.g. <code>$options['options_banner_text']</code>).

I discovered that if I include the language code between the ACF option slug and the field key, WPML returns the correct translation:
<code>// Correctly returns English translation:
echo $options['options_en_banner_text'];</code>

Symptoms:
I always get the default-language value, even after switching languages in the front end or admin. The value is never the translated string unless I manually include the language code in the option key.

Questions:
Is this a known limitation or bug in WPML’s handling of ACF Option Pages?
If it’s a bug, when might we expect a fix?
If this behavior is intentional, is there a recommended 'official' way to load translated option values without manually renaming the keys?

May 1, 2025 at 4:37 am #16985585

Bigul
WPML Supporter since 01/2013

Languages: English (English )

Timezone: Europe/Vienna (GMT+02:00)

Hello,

Welcome to the WPML support forum. I will do my best to help you resolve the issue.

As per the official ACF documentation, we have to use the following code to retrieve the option values.

//Retrieve a field
$variable = get_field('field_name', 'option');

//Display a field
<p><?php the_field('field_name', 'option'); ?></p>

So please try it after a site backup and let us know your feedback.

Refer to the following doc for more information:

hidden link

https://wpml.org/documentation/related-projects/translate-sites-built-with-acf/translating-the-acf-options-page-custom-fields-with-wpml/

--
Thanks!

Bigul

May 2, 2025 at 11:24 am #16989318

Angeloca

Yes it's working that way, but I usually prefer using wordpress standard functions over acf ones.

But please let me know if it's the exptected behaviour for WPML to store translations in options_[lang]_key format in the DB.

May 2, 2025 at 5:12 pm #16990421

Bigul
WPML Supporter since 01/2013

Languages: English (English )

Timezone: Europe/Vienna (GMT+02:00)

Hello,

Thank you for the feedback. This is the expected behavior.

For ACF options, the values are saved after switching to the secondary language (please refer to the following screenshots). In this case, the secondary language values are stored in the database with a language code suffix, such as options_en_banner_text.

hidden link

hidden link

In short, we switch the language and save the options separately for each language. Thank you for your kind understanding.

--
Thanks!

Bigul

May 5, 2025 at 9:18 am #16995398

Angeloca

Hi Bigul, thanks!

Is it not possible to translate them in another way (like string translation) so that i can always load the option (using wp functions) without the language slug?

thanks 🙂

May 5, 2025 at 3:10 pm #16997055

Bigul
WPML Supporter since 01/2013

Languages: English (English )

Timezone: Europe/Vienna (GMT+02:00)

Hello,

Thank you for the updates. However, there are limitations when it comes to translating ACF Options Page values directly using String Translation, as they are stored as custom field values by ACF.

Therefore, to translate them using String Translation, you will need to follow these steps:

1) Register the ACF Option Page values in String Translation using the wpml_register_single_string hook.

2) Translate the registered strings in WPML String Translation.

3) Display the translated strings using the wpml_translate_single_string hook.

Please refer to the following documentation for more details.

https://wpml.org/wpml-hook/wpml_register_single_string/

https://wpml.org/wpml-hook/wpml_translate_single_string/

--
Thanks!

Bigul