Я использую WordPress для нескольких сайтов.У меня есть требование, где я хочу добавить поле в существующую группу повторителей ACF. Ниже я попробовал.
add_action('acf/init','add_field');
function add_field(){
acf_add_local_field(array(
'key' => 'field_asdfaas1234ww',
'label' => 'price_xyz',
'name' => 'price_xyz',
'type' => 'text',
'instructions' => '',
'parent' => 'field_568a6ed7971d2',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array (
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'formatting' => 'html',
'maxlength' => '',));
}
Ниже приведен код экспорта для этой существующей группы ACF, просто для справки.
if( function_exists('acf_add_local_field_group') ):
acf_add_local_field_group(array (
'key' => 'group_59ce208402798',
'title' => 'price_group',
'fields' => array (
array (
'key' => 'field_568a6ed7971d2',
'label' => 'pricing',
'name' => 'pricing',
'type' => 'repeater',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array (
'width' => '',
'class' => '',
'id' => '',
),
'row_min' => '',
'row_limit' => '',
'layout' => 'table',
'button_label' => 'Add Row',
'min' => 0,
'max' => 0,
'collapsed' => '',
'sub_fields' => array (
array (
'key' => 'field_568a6f4f971d3',
'label' => 'group_name',
'name' => 'group_name',
'type' => 'taxonomy',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array (
'width' => '',
'class' => '',
'id' => '',
),
'taxonomy' => 'product_cat',
'field_type' => 'select',
'allow_null' => 0,
'load_save_terms' => 0,
'return_format' => 'id',
'multiple' => 0,
'add_term' => 1,
'load_terms' => 0,
'save_terms' => 0,
),
array (
'key' => 'field_568a6f65971d4',
'label' => 'width',
'name' => 'width',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array (
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'formatting' => 'html',
'maxlength' => '',
),
array (
'key' => 'field_568a72a5ffda9',
'label' => 'no_of_doors',
'name' => 'no_of_doors',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array (
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'formatting' => 'html',
'maxlength' => '',
),
array (
'key' => 'field_568a72baffdaa',
'label' => 'price_norway',
'name' => 'price_norway',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array (
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'formatting' => 'html',
'maxlength' => '',
),
array (
'key' => 'field_568b5cae9ff93',
'label' => 'price_swedish',
'name' => 'price_swedish',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array (
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'formatting' => 'html',
'maxlength' => '',
),
),
),
),
'location' => array (
array (
array (
'param' => 'post_type',
'operator' => '==',
'value' => 'product',
),
),
),
'menu_order' => 0,
'position' => 'normal',
'style' => 'seamless',
'label_placement' => 'top',
'instruction_placement' => 'label',
'hide_on_screen' => '',
'active' => 1,
'description' => '',
));
endif;
Но по какой-то причине я не могу добавить поле с помощью своего кода function add_field
.Можете ли вы, ребята, помочь