Home Forums Add-ons Options Page Update Options page for specific language


Update Options page for specific language

  • Hi,
    I’m trying to update fields on an options page but for a specific language (multilanguage site).

    I’ve found this on the forums but it doesn’t seem to work:

    update_field(LANG_CODE . '_' . FIELD_NAME, FIELD_VALUE, 'options');

    Any ideas?

    Using ACF Pro and WPML the latest versions.

  • This is how the acf added the language for options:

        // 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…


Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Update Options page for specific language’ is closed to new replies.