Home › Forums › ACF PRO › acf add local field to flexible content › Reply To: acf add local field to flexible content
thanks for your help. this is working now. it was related to another issue
<?php if( function_exists('acf_add_local_field_group') ) {
acf_add_local_field_group(
array (
'key' => 'group_56ff5b11d1775',
'title' => 'add component',
'fields' => array (
array (
'key' => 'field_flex_key',
'label' => 'flexible content',
'name' => 'flexible_content',
'type' => 'flexible_content',
'instructions' => '',
'wrapper' => array (
'width' => '',
'class' => '',
'id' => '',
),
'button_label' => 'Add Row',
'min' => '',
'max' => '',
'layouts' => array (
array (
'key' => 'layout_key',
'name' => 'sample_label',
'label' => 'sample label',
'display' => 'block',
'min' => '',
'max' => '',
),
),
),
),
'location' => array (
array (
array (
'param' => 'post_type',
'operator' => '==',
'value' => 'post',
),
),
),
'menu_order' => 0,
'position' => 'normal',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'hide_on_screen' => '',
'active' => 1,
'description' => '',
)
);
acf_add_local_field(
array (
'key' => 'field_57032097d3ac0',
'label' => 'Content Columns',
'name' => 'content_columns',
'type' => 'tab',
'parent' => 'field_flex_key', //flex field key
'parent_layout' => 'layout_key', // layout key
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array (
'width' => '',
'class' => '',
'id' => '',
),
'placement' => 'top',
'endpoint' => 0,
)
);
acf_add_local_field(
array (
'key' => 'field_repeatable_key',
'label' => 'Repeatable image with optional link',
'name' => 'repeatable_imgs',
'type' => 'repeater',
'parent' => 'field_flex_key', //flex field key
'parent_layout' => 'layout_key', // layout key
'row_min' => 0,
'row_limit' => '',
'layout' => 'table',
'button_label' => 'Add image',
)
);
acf_add_local_field(
array (
'key' => 'field_5237950f6c6e4',
'label' => 'url',
'name' => 'img_link_url',
'type' => 'text',
'parent' => 'field_repeatable_key',
)
);
acf_add_local_field(
array (
'key' => 'field_styling_tab',
'label' => 'Row Styling',
'name' => 'row_styling',
'type' => 'tab',
'parent' => 'field_flex_key', //flex field key
'parent_layout' => 'layout_key', // layout key
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array (
'width' => '',
'class' => '',
'id' => '',
),
'placement' => 'top',
'endpoint' => 0,
)
);
acf_add_local_field(
array (
'key' => 'field_570320bbd3ac1',
'label' => 'row class',
'name' => 'row_class',
'type' => 'text',
'parent' => 'field_flex_key', //flex field key
'parent_layout' => 'layout_key', // layout key
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array (
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'maxlength' => '',
'readonly' => 0,
'disabled' => 0,
)
);
}
?>
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.