Hello everyone
I am using ACF Pro and embedded a code referencing the page below to loop the values assigned to a checkbox field:
https://www.advancedcustomfields.com/resources/checkbox/
The code embedded is shown as follows:
<?php $toilets = get_field(‘toilets’);
if($toilets): ?>
<?php foreach($toilets as $toilet): ?>
<?php echo $toilet[value]; ?>
<?php endforeach; ?>
<?php endif; ?>
The error returned is:
Warning: Invalid argument supplied for foreach() in…
Also, what echo returns for the value of get_field(‘toilets’) is:
s:41:”s:33:”a:1:{i:0;s:15:”indoor toilet”;}”;”;
Does this mean the checkbox field does NOT produce an array?
Could someone tell me how you can display entered values of a checkbox field only?
Thank you in advance,
Ead
You can define the output value of the checkboxes. Did you choose “output as array”?
Also important: Are you using the get_field() within a WordPress loop? If not, you have to enter a post id. (get_field)