Home › Forums › Front-end Issues › Displaying multiple select field labels › Reply To: Displaying multiple select field labels
I’m trying to apply this to an option page, but cannot get it to work.
$labels = array();
$field = get_field_object( 'sidebar_home', 'option' );
$values = get_field( 'sidebar_home', 'option' );
foreach ($values as $value) {
$labels[] = $field['choices'][ $value ];
}
//And this is how I'm displaying it
<?php echo implode(', ', $labels); ?>
I’m getting an “Illegal offset type” error.
My select field is set to multiple choices and a return format of “Both (Array)”.
Any clues of why I’m getting that error?
Thanks!
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.