Home › Forums › ACF PRO › Programmatic Location Rules › Reply To: Programmatic Location Rules
Hey John!
Thanks for pointing me in the right direction, this is what’ I’m using and it seems to accomplish what I need.
add_filter('acf/get_field_group', 'my_change_field_group');
function my_change_field_group($group) {
$get_current_screen = get_current_screen();
$get_current_post_type = $get_current_screen->post_type;
$my_option = get_field('my-option','option');
if (
$get_current_post_type == 'my-cpt' &&
$my_option == 'stuff' &&
$group['key'] == 'group_123456789'
) {
$group['location'] = array(
array(
array(
'param' => 'post_type',
'operator' => '==',
'value' => 'my-cpt',
),
),
);
}
return $group;
};
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!
🚀 ACF & ACF PRO 6.0.7 are now available.
— Advanced Custom Fields (@wp_acf) January 18, 2023
✨This release contains bug fixes and improvements while we continue to work on the next major release of ACF.https://t.co/wQgAOpwmUI
© 2023 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.