Home › Forums › Front-end Issues › Display Labels of Checkbox Field › Reply To: Display Labels of Checkbox Field
Trying the above code is causing a warning error to be thrown with my usage and I don’t understand why.
Warning: Invalid argument supplied for foreach()
<?php
$portfolioContent = get_field('portfolio_content'); // this is the group field
if ($portfolioContent) :
$skills = $portfolioContent['skills'];
$field = get_field_object($skills);
?>
<h1><?php echo $subTitle; ?></h1>
<?php
if ($skills) : ?>
<ul>
<?php foreach ($field['choices'] as $v => $l) : ?>
<li><?php echo $l; ?></li>
<?php endforeach; ?>
</ul>
<?php endif;
?>
<?php endif;
?>
$skills = the checkboxes
print_r($skills);
// return value = value
Array ( [0] => wordPress [1] => javascript [2] => jquery [3] => scss [4] => responsive-design [5] => photoshop [6] => illustrator )
// return value = both
Array ( [0] => Array ( [value] => wordPress [label] => WordPress ) [1] => Array ( [value] => javascript [label] => Javascript ) [2] => Array ( [value] => jquery [label] => jQuery ) [3] => Array ( [value] => scss [label] => SCSS ) [4] => Array ( [value] => responsive-design [label] => Responsive Design ) [5] => Array ( [value] => photoshop [label] => Photoshop ) [6] => Array ( [value] => illustrator [label] => Illustrator ) )
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.