wp_save_revisioned_meta_fields

函式
wp_save_revisioned_meta_fields ( $revision_id, $post_id )
引數
  • (int) $revision_id The ID of the revision to save the meta to.
    Required:
  • (int) $post_id The ID of the post the revision is associated with.
    Required:
定義位置
相關方法
wp_autosave_post_revisioned_meta_fieldswp_post_revision_meta_keys_wp_post_revision_fieldswp_check_revisioned_meta_fields_have_changedwp_save_post_revision_on_insert
引入
6.4.0
棄用
-

儲存已修訂的元欄位。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function wp_save_revisioned_meta_fields( $revision_id, $post_id ) {
$post_type = get_post_type( $post_id );
if ( ! $post_type ) {
return;
}
foreach ( wp_post_revision_meta_keys( $post_type ) as $meta_key ) {
if ( metadata_exists( 'post', $post_id, $meta_key ) ) {
_wp_copy_post_meta( $post_id, $revision_id, $meta_key );
}
}
}
function wp_save_revisioned_meta_fields( $revision_id, $post_id ) { $post_type = get_post_type( $post_id ); if ( ! $post_type ) { return; } foreach ( wp_post_revision_meta_keys( $post_type ) as $meta_key ) { if ( metadata_exists( 'post', $post_id, $meta_key ) ) { _wp_copy_post_meta( $post_id, $revision_id, $meta_key ); } } }
function wp_save_revisioned_meta_fields( $revision_id, $post_id ) {
	$post_type = get_post_type( $post_id );
	if ( ! $post_type ) {
		return;
	}

	foreach ( wp_post_revision_meta_keys( $post_type ) as $meta_key ) {
		if ( metadata_exists( 'post', $post_id, $meta_key ) ) {
			_wp_copy_post_meta( $post_id, $revision_id, $meta_key );
		}
	}
}

常見問題

FAQs
檢視更多 >