acf-builder-cheatsheet
acf-builder-cheatsheet copied to clipboard
Add example with conditional logic
Not sure if I am missing this somewhere, but I can't seem to figure out how to implement conditional logic for a field. I tried:
'conditional_logic' => [ 'include_call_to_action', '==', 0],
and:
[ 'include_call_to_action' => 1],
Neither is working. It would be great to have an example that uses conditional logic.
When you have doubts of this type, a good practice is to generate the field with the graphical interface and then export the PHP with the ACF tool. So you can see what the notation is like. Here is an example of conditional logic.
'conditional_logic' => [
[
[
'field' => 'single_project_type',
'operator' => '==',
'value' => 'image',
]
]
],
That's a great idea. Didn't think of that. I wonder if that tip should be at the top as a catch all? I can make a PR and add it if it seems worth it.