wpseek.com
A WordPress-centric search engine for devs and theme authors
_wp_copy_post_meta › WordPress Function
Since6.4.0
Deprecatedn/a
› _wp_copy_post_meta ( $source_post_id, $target_post_id, $meta_key )
Parameters: (3) |
|
Defined at: |
|
Codex: |
Copy post meta for the given key from one post to another.
Related Functions: wp_login_viewport_meta, wp_get_post_tags, update_post_meta, add_post_meta, wp_set_post_tags
Source
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 ) ); } }