Home › Forums › General Issues › Issue: WPML support: using repeatable fields in option fields › Reply To: Issue: WPML support: using repeatable fields in option fields
We ran into the exact same problem when using repeater fields in theme options.
I found the culprit, but there is probably not an easy way hook or filter it away. It’s right there in
get_fields_objects(). When ACF saves a theme option in a different language, it appends the language code to the option name, like this:
Default language (German):
Other language (English):
get_fields_objects() function runs a direct query on the database, with the following SELECT for the default language:
SELECT option_name, option_value FROM wp_options WHERE option_name LIKE 'options_%' OR option_name LIKE '_options_%'
When when we compare it to the query which is run for the English options, we see that is looks explicitly for options with the language code:
SELECT option_name, option_value FROM wp_options WHERE option_name LIKE 'options_en_%' OR option_name LIKE '_options_en_%'
The problem here is, that for the default language, it also matches options with language codes suffixes from other languages. So the English options are loaded as well. ACF then can’t correctly set a value and overwrites the values for the default language with the additionally loaded values from another language.
Now I don’t know how this is solved best. I guess either the query has to be adapted to filter out all other languages or they have to be filtered out after the query.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!