acf_field_clone::acf_clone_clone_field()publicACF 5.3.8


This function is run when cloning a clone field Important to run the acf_clone_field function on sub fields to pass on settings such as 'parent_layout' Do not delete! Removing this logic causes major issues with cloned clone fields within a flexible content layout.

Метод класса: acf_field_clone{}

Хуков нет.




$acf_field_clone = new acf_field_clone();
$acf_field_clone->acf_clone_clone_field( $field, $clone_field );
$field (обязательный)
$clone_field (обязательный)

Список изменений

С версии 5.3.8 Введена.

Код acf_field_clone::acf_clone_clone_field() ACF 6.0.4

function acf_clone_clone_field( $field, $clone_field ) {

	// modify the $clone_field name
	// This seems odd, however, the $clone_field is later passed into the acf_clone_field() function
	// Do not delete!
	// when cloning a clone field, it is important to also change the _name too
	// this allows sub clone fields to appear correctly in get_row() row array
	if ( $field['prefix_name'] ) {

		$clone_field['name']  = $field['_name'];
		$clone_field['_name'] = $field['_name'];


	// bail early if no sub fields
	if ( empty( $field['sub_fields'] ) ) {
		return $field;

	// loop
	foreach ( $field['sub_fields'] as &$sub_field ) {

		// clone
		$sub_field = acf_clone_field( $sub_field, $clone_field );


	// return
	return $field;