acf_field_taxonomy::get_termspublicACF 5.0.0

This function will return an array of terms for a given field value

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

Хуков нет.

Возвращает

$value.

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

$acf_field_taxonomy = new acf_field_taxonomy();
$acf_field_taxonomy->get_terms( $value, $taxonomy );
$value(обязательный)
.
$taxonomy
.
По умолчанию: 'category'

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

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

Код acf_field_taxonomy::get_terms() ACF 6.4.2

function get_terms( $value, $taxonomy = 'category' ) {

	// load terms in 1 query to save multiple DB calls from following code
	if ( count( $value ) > 1 ) {
		$terms = acf_get_terms(
			array(
				'taxonomy'   => $taxonomy,
				'include'    => $value,
				'hide_empty' => false,
			)
		);
	}

	// update value to include $post
	foreach ( array_keys( $value ) as $i ) {
		$value[ $i ] = get_term( $value[ $i ], $taxonomy );
	}

	// filter out null values
	$value = array_filter( $value );

	// return
	return $value;
}