_wp_copy_post_meta

函数
_wp_copy_post_meta ( $source_post_id, $target_post_id, $meta_key )
参数
  • (int) $source_post_id Post ID to copy meta value(s) from.
    Required:
  • (int) $target_post_id Post ID to copy meta value(s) to.
    Required:
  • (string) $meta_key Meta key to copy.
    Required:
定义位置
相关方法
wp_login_viewport_metawp_get_post_tagsupdate_post_metaadd_post_metawp_set_post_tags
引入
6.4.0
弃用
-

将给定关键字的post meta从一个文章复制到另一个文章。

function _wp_copy_post_meta( $source_post_id, $target_post_id, $meta_key ) {

	foreach ( get_post_meta( $source_post_id, $meta_key ) as $meta_value ) {
		/**
		 * We use add_metadata() function vs add_post_meta() here
		 * to allow for a revision post target OR regular post.
		 */
		add_metadata( 'post', $target_post_id, $meta_key, wp_slash( $meta_value ) );
	}
}

常见问题

FAQs
查看更多 >
闪电侠

(工作日 10:00 - 18:30 为您服务)

2025-12-07 11:33:41

您好,无论是售前、售后、意见建议……均可通过联系工单与我们取得联系。

您也可选择聊天工具与我们即时沟通或点击查看:

您的工单我们已经收到,我们将会尽快跟您联系!
取消
选择聊天工具: