Hello! I am using ACF Pro and I want my fields to generate automatically when my custom plugin is activated, so I did like this:
add_action( 'plugins_loaded', array( $this, 'generate_acf_fields' ) );
public function generate_acf_fields() {
if( function_exists('acf_add_local_field_group') ):
acf_add_local_field_group(array(
'key' => 'group_60c28c944a319',
'title' => 'Team',
'fields' => array(
array(
'key' => 'field_60c28ca06cf2a',
'label' => 'Position',
'name' => 'position',
'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' => 'team',
),
),
),
'menu_order' => 0,
'position' => 'normal',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'hide_on_screen' => '',
'active' => true,
'description' => '',
));
endif;
}
But it is not generating at all, what is the reason of that?