Home › Forums › General Issues › Use conditional logic across another group? › Reply To: Use conditional logic across another group?
New project with only the ACF plugin (PRO) installed (5.10.2).
I put this inside functions.php (generated by ACF and then modified to use the field key inside the conditional_logic array) :
if( function_exists('acf_add_local_field_group') ):
acf_add_local_field_group(array(
'key' => 'group_616de148bf2ce',
'title' => 'page after title',
'fields' => array(
array(
'key' => 'field_616de15b4155f',
'label' => 'Field in after-title group',
'name' => 'test',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'maxlength' => '',
),
),
'location' => array(
array(
array(
'param' => 'post_type',
'operator' => '==',
'value' => 'page',
),
),
),
'menu_order' => 0,
'position' => 'acf_after_title',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'hide_on_screen' => '',
'active' => true,
'description' => '',
));
acf_add_local_field_group(array(
'key' => 'group_616de1da31d45',
'title' => 'page normal',
'fields' => array(
array(
'key' => 'field_616de1eb45ead',
'label' => 'Field in normal group',
'name' => 'hiding',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => [
[
[
'field' => 'field_616de15b4155f',
'operator' => '!=',
'value' => 'test'
]
]
],
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'maxlength' => '',
),
),
'location' => array(
array(
array(
'param' => 'post_type',
'operator' => '==',
'value' => 'page',
),
),
),
'menu_order' => 0,
'position' => 'normal',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'hide_on_screen' => '',
'active' => true,
'description' => '',
));
endif;
I can see both fields on the page, but when I type “test” into the first one (inside the after-title group), nothing happens (the second field inside the normal group should disappear).
BTW : thank you for your time ! It is really appreciated
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!
Our guide looks into WordPress custom fields and how they stack up against the possibilities of ACF.
— Advanced Custom Fields (@wp_acf) July 18, 2022
https://t.co/hk3yibkHyk
© 2022 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.