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;
}
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.