Home › Forums › Front-end Issues › Displaying multiple select field labels › Reply To: Displaying multiple select field labels
Hey wearegiants,
thank you for this hint. Actually with your piece of code you only get the label of a single selected value.
Use this code if you want to store all labels in one array ($labels):
$labels = array();
$field = get_field_object('fieldname');
$values = get_field('fieldname');
foreach ($values as $value) {
$labels[] = $field['choices'][ $value ];
}
For outputting the labels:
foreach ($labels as $label) {
echo $label;
}
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.