Support

Account

Home Forums Front-end Issues get_field_object and WPML Reply To: get_field_object and WPML

  • Is hardcoding your array of options a viable solution?

    $project_scope = array(
    	'key1' => __('value1', 'text-domain'),
    	'key2' => __('value2', 'text-domain'),
    	'key3' => __('value3', 'text-domain'),
    )

    WPML string translation could scan all values wrapped in __() and you can easily translate them.

    If you still want these values to be available in an ACF select field, you can dynamically populate that field using the same source:

    add_filter('acf/load_field/name=project_scope', 'my_project_scope_options');
    function my_project_scope_options( $field ) {
    	global $project_scope;
        $field['choices'] = $project_scope; //You can do this because it already is an associative array
        return $field;   
    }