Support

Account

Home Forums General Issues How to display default language Options field, when no WPML translation exists Reply To: How to display default language Options field, when no WPML translation exists

  • Hi @infoamitywebsolutions-co-uk

    The options page has different values between the master and translated version to make sure that you can set different values for them. The option values are saved in the wp_options table for both site. For the master site, it’s saved with this option name:

    options_field_name

    Where “field_name” is your field name. For the translated version, it uses the country iso code like this:

    options_de_field_name

    To get the option values from the master version, you need to set the current language with the master site iso code. You can also automatically do it by using the acf/load_value. It should be something like this:

    function my_acf_load_value( $value, $post_id, $field )
    {
        if( $post_id == 'options_de' && !$value ){
            
            //set the current language to EN temporarily
            add_filter('acf/settings/current_language', function(){return 'en';});
    
            $value = get_field($field['name'], 'options', false);
    
            //set it back to DE
            add_filter('acf/settings/current_language', function(){return 'de';});
            
        }
        
        return $value;
    }
    
    // acf/load_value - filter for every value load
    add_filter('acf/load_value', 'my_acf_load_value', 20, 3);

    I hope this helps 🙂