ACF\Meta

MetaLocation::get_referencepublicACF 6.4

Gets a reference key for the provided field name.

Method of the class: MetaLocation{}

No Hooks.

Returns

String|null.

Usage

$MetaLocation = new MetaLocation();
$MetaLocation->get_reference( $object_id, $field_name );
$object_id(int|string)
The ID of the object to get the reference key from.
$field_name(string)
The name of the field to get the reference for.
Default: ''

Changelog

Since 6.4 Introduced.

MetaLocation::get_reference() code ACF 6.8.8

public function get_reference( $object_id = 0, $field_name = '' ) {
	$reference = get_metadata( $this->location_type, $object_id, $this->reference_prefix . $field_name );
	return $reference[0] ?? null;
}