Hi,
I am trying to access the content of ACF options fields in a specific language.
For example I have a field called “email_text”. This field is available in English and German.
Now I’d like to always get the German email_text value, irregardless of which language is currently active.
I’ve found this snippet in your docs, which I am currently using:
$lang = $_POST['lang'];
add_filter('acf/settings/default_language', 'my_acf_settings_default_language');
function my_acf_settings_default_language( $language ) {
if($lang == "") $lang = "de";
return $lang;
}
However it just returns an empty value, if I access the options page field like so right below the above function:
$message = get_field('email_text', 'options');
Do you guys know a solution to this?
Renaming the fields to en_email_text, de_email_text, etc. is not an option.
Thanks!
Hi @philex
ACF uses the setting ‘current_language’ to modify the $post_id
, not the ‘default_language’.
I believe it would be possible to simply use this code instead of the filter:
$message = get_field('email_text', 'options_de');
You can check your wp_options table to double check what the language code is used in the option_name.
Thanks
E