acf_get_meta_instance()ACF 6.4

Retrieves an ACF meta instance for the provided meta type.

No Hooks.

Returns

Object|null.

Usage

acf_get_meta_instance( $type ): ?object;
$type(string) (required)
The meta type as decoded from the post ID.

Changelog

Since 6.4 Introduced.

acf_get_meta_instance() code ACF 6.8.8

function acf_get_meta_instance( string $type ): ?object {
	$instance       = null;
	$meta_locations = acf_get_store( 'acf-meta-locations' );

	if ( $meta_locations && $meta_locations->has( $type ) ) {
		$instance = acf_get_instance( $meta_locations->get( $type ) );
	}

	return $instance;
}