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;