acf_field_flexible_content::get_sub_field()publicACF 5.4.0

get_sub_field

This function will return a specific sub field

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

Хуков нет.

Возвращает

$post_id. (int)

Использование

$acf_field_flexible_content = new acf_field_flexible_content();
$acf_field_flexible_content->get_sub_field( $sub_field, $id, $field );
$sub_field (обязательный)
-
$id (обязательный)
-
$field (обязательный)
-

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

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

Код acf_field_flexible_content::get_sub_field() ACF 6.0.4

function get_sub_field( $sub_field, $id, $field ) {

	// Get active layout.
	$active = get_row_layout();

	// Loop over layouts.
	if ( $field['layouts'] ) {
		foreach ( $field['layouts'] as $layout ) {

			// Restict to active layout if within a have_rows() loop.
			if ( $active && $active !== $layout['name'] ) {
				continue;
			}

			// Check sub fields.
			if ( $layout['sub_fields'] ) {
				$sub_field = acf_search_fields( $id, $layout['sub_fields'] );
				if ( $sub_field ) {
					break;
				}
			}
		}
	}

	// return
	return $sub_field;
}