Created
February 13, 2020 08:02
-
-
Save alejandrogih/fc79e22dd7d9c65048689a4bc12e0dce to your computer and use it in GitHub Desktop.
Wordpress duplicate post meta function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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