This thread is resolved. Here is a description of the problem and solution.
Problem: You have translated an ACF field group that includes a select field with three values. While the backend displays the translated values correctly, the frontend still shows the original strings. Solution: The issue stems from your theme's template file. The 'illegal string offset' warning typically arises when attempting to access an array element with a string key, but the variable in question is not an array. This discrepancy explains why you encounter no error when 'Both' is an object (Array) and 'Label' is a string. We recommend following the ACF documentation on how to properly display fields in your theme. You can find the necessary guidelines here: ACF Documentation on Select Fields
If this solution does not resolve your issue, or if it seems outdated or irrelevant to your case, please open a new support ticket. We also 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.
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.
Background of the issue:
I have translated an ACF field group that contains a select field with 3 values. I translated these 3 values, on the backend I see the change.
Symptoms:
On the frontend, it still shows the original string.
Questions:
Do I need to change the syntax of the "select" values in order for the translations to work properly?
Languages: English (English )Spanish (Español )German (Deutsch )
Timezone: America/Lima (GMT-05:00)
Hello,
Please make sure that the ACF Field Groups are set to "Not translateable" inside WPML > Settings > Post Type Translation. In case you translated the groups please delete any duplicated/translated groups.
---
It sounds as if you translated the choices successfully with the WPML Translation Editor or directly with WPML String Translation.
How are you rendering the select's choices on the Frontend?
Are you using a PHP Template? If so, could you please paste me the code that outputs the select field on Frontend?
---
Also, please verify if the current memory usage might be close to or above 128MB. You can find this detail at WPML > Support PHP.
Here's how I fixed it after the fields have been translated:
- I changed the return format of my select to "Both (Array)"
- In my PHP template I returned the label instead with this code: <?php echo esc_html($level['label']); ?>
Languages: English (English )Spanish (Español )German (Deutsch )
Timezone: America/Lima (GMT-05:00)
This is an error coming from your theme's template file.
The "illegal string offset" warning usually occurs when you're trying to access an array element using a string key, but the variable you're working with isn't actually an array.
This is why you do not get an error when returning "Both" is an object (Array) and "Label" is a string.
Please follow ACF's documentation on how to display the fields correctly in your theme.
hidden link
Manage Cookie Consent
We use cookies to optimize our website and services. Your consent allows us to process data such as browsing behavior. Not consenting may affect some features.
Functional
Always active
Required for our website to operate and communicate correctly.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
We use these to analyze the statistics of our site. Collected information is completely anonymous.The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
These cookies track your browsing to provide ads relevant to you.