WordpressNoob99
WordpressNoob99

Reputation: 23

How can I hide/show advanced custom fields based on selection of a select field?

I created some advanced custom fields. One of them is a select field, where you can choose between sale and charter.

I want to hide/show some of my advanced custom fields based on what is currently selected (sale or charter).

How can I do this?

Upvotes: 1

Views: 3185

Answers (2)

git-e-up
git-e-up

Reputation: 904

The other answer covers the back end. For the front end template, something like this:

if (get_field('select_field_name') == 'sale'){
    //show some stuff i.e. the_field('field_name');
}
elseif (get_field('select_field_name') == 'charter') {
    //show other fields
}
else {
    //maybe do something here
}

Upvotes: 0

Vivek Rabara
Vivek Rabara

Reputation: 26

ACf Image

As shown in image (Click link) there is an option in the ACF to show fields conditionally based on other fields value whether it is Checkbox or Select box.

Upvotes: 1

Related Questions