Home › Forums › ACF PRO › Adding locations to a field group › Reply To: Adding locations to a field group
ok, I’m almost there 🙂
I modified the code like this :
add_filter('acf/get_field_group', 'my_modify_field_group_function');
function my_modify_field_group_function($group) {
if ($group['key'] != 'group_58c6bfd3a0239') { // note: I replaced $field with $group
// not our field group
return;
} else {
// add an OR rule to existing location rules for a specific field group
$group['location'] = array(
array (
array (
'param' => 'post_type',
'operator' => '==',
'value' => 'portfolio',
),
),
array (
array (
'param' => 'post_type',
'operator' => '==',
'value' => 'team',
),
),
array (
array (
'param' => 'post_type',
'operator' => '==',
'value' => 'page',
),
),
array (
array (
'param' => 'post_type',
'operator' => '==',
'value' => 'post',
),
)
);
return $group;
}
}
Now it’s working, I have the field group of my plugin available for portfolio and team. But the problem is that I cannot manually create other field groups… They appear inactive, and the fields seems not saved!
the the screenshots without the filter, and with the filter
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.