Support

Account

Home Forums ACF PRO Multiple Select

Solved

Multiple Select

  • 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';
    }
    
Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.