acf_copy_metadata()ACF 5.3.8

Copies meta from one post to another. Useful for saving and restoring revisions.

Хуков нет.

Возвращает

null. Ничего (null).

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

acf_copy_metadata( $from_post_id, $to_post_id );
$from_post_id(int|строка)
The post id to copy from.
$to_post_id(int|строка)
The post id to paste to.

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

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

Код acf_copy_metadata() ACF 6.4.2

function acf_copy_metadata( $from_post_id = 0, $to_post_id = 0 ) {
	// Get all metadata.
	$meta = acf_get_meta( $from_post_id );

	$decoded  = acf_decode_post_id( $to_post_id );
	$instance = acf_get_meta_instance( $decoded['type'] );

	if ( $meta && $instance ) {
		$instance->update_meta( $decoded['id'], $meta );
	}
}