ACF\Meta

MetaLocation::get_metapublicACF 6.4

Retrieves all ACF meta for the provided object ID.

Method of the class: MetaLocation{}

No Hooks.

Returns

Array.

Usage

$MetaLocation = new MetaLocation();
$MetaLocation->get_meta( $object_id ): array;
$object_id(int|string)
The ID of the object to get meta from.

Changelog

Since 6.4 Introduced.

MetaLocation::get_meta() code ACF 6.8.8

public function get_meta( $object_id = 0 ): array {
	$meta     = array();
	$all_meta = get_metadata( $this->location_type, $object_id );

	if ( $all_meta ) {
		foreach ( $all_meta as $key => $value ) {
			// If a reference exists for this value, add it to the meta array.
			if ( isset( $all_meta[ $this->reference_prefix . $key ] ) ) {
				$meta[ $key ]                           = $value[0];
				$meta[ $this->reference_prefix . $key ] = $all_meta[ $this->reference_prefix . $key ][0];
			}
		}
	}

	// Unserialize results and return.
	return array_map( 'acf_maybe_unserialize', $meta );
}