Skip to content

Instantly share code, notes, and snippets.

@alejandrogih
Created February 13, 2020 08:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alejandrogih/fc79e22dd7d9c65048689a4bc12e0dce to your computer and use it in GitHub Desktop.
Save alejandrogih/fc79e22dd7d9c65048689a4bc12e0dce to your computer and use it in GitHub Desktop.
Wordpress duplicate post meta function
function copy_post_meta($base_post,$post_id){
$new_meta = get_post_meta($base_post);
foreach ($new_meta as $key => $value) {
$new_value = maybe_unserialize($value[0]);
update_post_meta( $post_id, $key, $new_value );
}
}
function copy_post_meta($base_post,$post_id){$new_meta = get_post_meta($base_post);foreach ($new_meta as $key => $value) {$new_value = maybe_unserialize($value[0]);update_post_meta( $post_id, $key, $new_value ) ;}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment