Home › Forums › Front-end Issues › Checkbox key =>value and gettext calls
Hello,
I am using ACF custom fields in a theme that uses WPML and am having some trouble with translating checkbox fields. I am including ACF custom fields in the theme itself using define( ‘ACF_LITE’ , true ); and have wrapped the values displayed on the frontend like so :
array (
'key' => 'field_52dcf154e272e',
'label' => __('Selling Points', 'hostel_mama' ),
'name' => 'selling_points',
'type' => 'checkbox',
'instructions' => __('Check 4 items', 'hostel_mama' ),
'choices' => array (
__('Bed linens included', 'hostel_mama') => 'Bed linens included',
__('Full bed linens included', 'hostel_mama') => 'Full bed linens included',
__('Free WIFI and Internet Access', 'hostel_mama' ) => 'Free WIFI and Internet Access',
__('Free (in-room) WIFI', 'hostel_mama' ) => 'Free (in-room) WIFI',
__('Breakfast included', 'hostel_mama' ) => 'Breakfast included',
__('Safe provided in room', 'hostel_mama' ) => 'Safe provided in room',
__('Individual room key', 'hostel_mama' ) => 'Individual room key',
),
'layout' => 'vertical',
),
The problem is that the key in the key=>value pair is being displayed on the frontend and the value is in admin. Only the value is translateable.
What do you mean by Only the value is translateable
The admin will display the value, but will save the key. This key will be returned to you on the front end.
I don’t see an issue here. Please let me know what I’m not seeing.
Thanks
E
Hi Eliot,
My problem was that I was using the [value] in the template -which was returned from the key. Problem solved by using:
$field = get_field_object('selling_points');
$points = get_field('selling_points');
foreach ( $points as $point ){
$label = $field['choices'][ $point];
echo '<li class="bullet-item">'.$label.'</li>';
}
}
(My thanks to Micheal on your support staff)
So happy, this tip help me. I cant say more than thank you to your website ! regards, netref
The topic ‘Checkbox key =>value and gettext calls’ is closed to new replies.
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.