Home › Forums › General Issues › Generate php – Where and how to put the code? › Reply To: Generate php – Where and how to put the code?
When I’m creating a field group in PHP I generally create an example group in ACF with the location rules I want, make sure it works and then export the code to see how it looks and then copy and paste the location value for the field group to the group I’m creating in PHP.
Location rules can be dynamically generated. Not exactly sure what you’re trying to do, so I can’t really give an example, but I usually still use ACF to give me examples of what I need to do.
You can modify a field group using the filter acf/load_field_group
, this is an undocumented filter.
add_filter('acf/load_field_group', 'my_custom_field_group_function');
function my_custom_field_group_function($group) {
if ($group['key'] != 'group_deal1') {
// not the group you want to modify
return $group;
}
// modify group attributes here
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!
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.