Home Forums Front-end Issues ACF Select Field IF a or b or d


ACF Select Field IF a or b or d

  • Hi,

    I have a Select type field. Multiple choice is not enabled, and you can only select one value. However, I want to display content only IF three certain specific values are selected.

    If the value is ‘available’ OR ‘underoffer’ OR ‘reserved’ then do something, else don’t display content etc

    I understand how to display this for one value, but when I try to incorporate OR operator the function does not work. Could somebody please help where I’m going wrong?

    Thank you.

    $statusofsale = get_field_object( 'property_listing_status', $post->ID ); 
    $statusofsale_value = $statusofsale['value'];
    if ($statusofsale_value == 'available' || 'underoffer' || 'reserved') {
    // Do Something
    } else {
    // Do Something
  • You either need to write out all of the ORs or use in array

    // if w/ ||s
    if ($statusofsale_value == 'available' || $statusofsale_value == 'underoffer' || $statusofsale_value == 'reserved') {


    / if w/in_array();
    if (in_array($statusofsale_value , array('available', 'underoffer', 'reserved'))) {
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.