Home › Forums › Add-ons › Options Page › Update Options page for specific language › Reply To: Update Options page for specific language
This is how the acf added the language for options:
\api\api-helpers.php:3027
// append language code
if( $post_id == 'options' ) {
$dl = acf_get_setting('default_language');
$cl = acf_get_setting('current_language');
if( $cl && $cl !== $dl ) {
$post_id .= '_' . $cl;
}
}
Basically, acf should automatically resolve if you just pass the ‘options’. However, if you were to update the value in a different language than you are currently on, you can temporarily switch acf’s current language setting.
For example, if your site’s default language is English. But you are currently in French and try to update the English’s field value, you can:
// store the currently language temporarily
$real_language = acf_get_setting('current_language');
// trick acf to the language you want
acf_update_setting('current_language', 'en');
update_field('field_name', 'some value', 'options');
// switch it back
acf_update_setting('current_language', $real_language);
I haven’t tested yet, but, should work…
Cheers
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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.