Support

Account

Home Forums ACF PRO Load ACF Sub Field Values

Unread

Load ACF Sub Field Values

  • 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;
    }
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.