Home › Forums › Add-ons › Flexible Content Field › Adding additional layout to flexible_content field in child theme › Reply To: Adding additional layout to flexible_content field in child theme
I did some testing, not sure if this will help you but it’s what I came up with. The only problem I can see is if you have additional field in the group and this would put your flex field at the end of the group.
<?php
add_action('init', 'add_a_layout', 20);
function add_a_layout() {
//echo 'here'; die;
$layout = array (
'key' => '56aab6d4e6272XXX',
'name' => 'layout_2',
'label' => 'layout 2',
'display' => 'block',
'sub_fields' => array (
array (
'key' => 'field_56aab6e3cba39XX',
'label' => 'test field 2',
'name' => 'test_field_2',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array (
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'maxlength' => '',
'readonly' => 0,
'disabled' => 0,
),
),
'min' => '',
'max' => '',
);
$field = acf_get_field('field_56aab6cdcba38');
$field['layouts'][] = $layout;
acf_remove_local_field('field_56aab6cdcba38');
acf_add_local_field($field);
}
?>
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.