0

So we have configured a filter to automatically populate ACF Fields from a custom post type and we have this working for a top-level flexible content block. However, we don't seem to be able to do the same for a nested flexible content. Block.

So in the example below, block 1 etc will be it's own flexible content field with it's set of fields. I'm hoping someone has someone can help. Thanks for your time everyone

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(
        //add block 1 This is also flexible with its own set of fields we need to auto populate. How do we reference this as a flex field and not just as a field of the parent. 
        'acf_fc_layout' => 'policy_statement',
      ),
      
      array(
        //add block 2  
        '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;
}

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.