wpseek.com
Un motore di ricerca WordPress per sviluppatori e autori di temi



_wp_copy_post_meta › WordPress Function

Da6.4.0
Deprecaton/a
_wp_copy_post_meta ( $source_post_id, $target_post_id, $meta_key )
Parametri: (3)
  • (int) $source_post_id Post ID to copy meta value(s) from.
    Richiesto:
  • (int) $target_post_id Post ID to copy meta value(s) to.
    Richiesto:
  • (string) $meta_key Meta key to copy.
    Richiesto:
Definito a:
Codex:

Copy post meta for the given key from one post to another.



Sorgenti

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 ) );
	}
}