Hi Guys, Im basically trying to load ACF sub field values on creation of a new custom post type. I have this working at a top level but Im having trouble drilling down to load sub field values when using sub flexible content fields. Can anyone help as I can’t find a reference in the documentation.
add_filter('acf/load_value/name=driving_for_work_policy_v2', 'add_starting_repeaterv2', 10, 3);
function add_starting_repeaterv2($value, $post_id, $field) {
if ($value !== NULL) {
// $value will only be NULL on a new post
return $value;
}
// add default layouts
$value = array(
array(
//this is the top level layout field
'acf_fc_layout' => 'policy_statement',
// this field just below is a sub flexible content field containing various sub field values which I'm currentlt having trouble loading
'policy_statement_section' => array(
array(
'acf_fc_layout' => 'policy_statement',
),
array(
'acf_fc_layout' => 'non_compliance',
),
array(
'acf_fc_layout' => 'policy_monitoring',
),
array(
'acf_fc_layout' => 'additional_section',
),
),
),
array(
//add block 2 these all work as they are not flex fields
'acf_fc_layout' => 'the_driver'
),
array(
//add block 3
'acf_fc_layout' => 'the_vehicle'
),
array(
//add block 4
'acf_fc_layout' => 'the_journey'
),
array(
//add block 5
'acf_fc_layout' => 'grey_fleet_drivers'
),
array(
//add block 6
'acf_fc_layout' => 'additional_section'
),
);
return $value;
}
You must be logged in to reply to this topic.
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.