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.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.