acf_get_reference()ACF 5.6.5

acf_get_reference

Retrieves the field key for a given field name and post_id.

Хуки из функции

Возвращает

Строку. The field key.

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

acf_get_reference( $field_name, $post_id );
$field_name(строка) (обязательный)
The name of the field. eg 'sub_heading'.
$post_id(разное) (обязательный)
The post_id of which the value is saved against.

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

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

Код acf_get_reference() ACF 6.0.4

function acf_get_reference( $field_name, $post_id ) {

	// Allow filter to short-circuit load_value logic.
	$reference = apply_filters( 'acf/pre_load_reference', null, $field_name, $post_id );
	if ( $reference !== null ) {
		return $reference;
	}

	// Get hidden meta for this field name.
	$reference = acf_get_metadata( $post_id, $field_name, true );

	/**
	 * Filters the reference value.
	 *
	 * @date    25/1/19
	 * @since   5.7.11
	 *
	 * @param   string $reference The reference value.
	 * @param   string $field_name The field name.
	 * @param   (int|string) $post_id The post ID where meta is stored.
	 */
	return apply_filters( 'acf/load_reference', $reference, $field_name, $post_id );
}