Home Forums ACF PRO Echo Only Chosen Option


Echo Only Chosen Option

  • I am working on a client’s site, and they are selling artwork. They want a red dot saying “Sold” to appear near to the artwork that has been sold. I am trying to figure out how to ONLY make that option appear if “Sold” was selected.

    This is what I have, but not sure if correct. :/

    <?php if(get_field('availability') == "Sold") { ?>
      <div><?php the_field(Sold'); ?></div>
    <?php } ?>
  • Nevermind, I figured it out. 🙂

    If anyone needs to show an ACF value if a specific option has been chosen, then here is the code for that. Feel free to use away!

    You will need to change the field types with your own field names and options though!

    `<!– artwork availability –>
    <?php if(get_field(‘availability’) == “Sold”): ?>
    <div class=”sold”><?php echo the_field(‘availability’); ?></div>
    <?php endif; ?>
    <!– ./artwork availability –>`

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.