Support

Account

Home Forums Add-ons Repeater Field Show field x if field y contains… Reply To: Show field x if field y contains…

  • You should look at the first code example that I gave then with the switch case based on the url field. A switch/case statement is the same as and if/elseif statement. The main difference is that it’s a lot cleaner.

    Think of it like this

    
    $bookingfield = get_field('accom_booking_link');
    
    if ($bookingfield == 'first url') {
    
    } elseif ($bookingfield == 'second url') {
    
    } elseif ($bookingfield == 'third case') {
    
    } elseif ($bookingfield == 'fourth case') {
    
    } else {
      // default case
    }
    

    This gets quite cumbersome after several elseif’s and is horrible to look at an manage, but can be done this way if you want. When dealing with many possibilities a switch statement can drastically reduce the amount of typing you need to do to code it.