I have a select box which allows multiple values to be select acf field (the field is called fruit). Something like this:
apples: apples
pears: pears
peaches: peaches
You can select all three sections of fruit.
I would like to query the acf select field so that even if all three fruits have been selected in the post type I can show just the one fruit.
i.e
<?php if( get_field(‘fruit’) === ‘apples’ ) { echo ‘<h3>Apples</h3>’; } ?>
Nothing shows for me if I try this?
Any help, greatly appreciated
Jonathan
A multi select field stores an array
$fruit = get_field('fruit');
if (in_array('apples'), $fruit)) {
echo 'Apples';
}