Home Forums Front-end Issues Checkbox key =>value and gettext calls


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.

  • Hi @mantismamita

    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.


  • 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)

  • Thanks, manti I have resolved this issue from this code.

  • After a long time, I am sharing 192.168.o.1.1 IP Information.

  • So happy, this tip help me. I cant say more than thank you to your website ! regards, netref

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

The topic ‘Checkbox key =>value and gettext calls’ is closed to new replies.