Skip to content

Instantly share code, notes, and snippets.

@eteubert
Last active December 14, 2015 11:19
Show Gist options
  • Select an option

  • Save eteubert/5077988 to your computer and use it in GitHub Desktop.

Select an option

Save eteubert/5077988 to your computer and use it in GitHub Desktop.
WordPress: copy comments between posts
<?php
// copy all comments from post $post_id to post $new_post_id
foreach ( get_comments( array( 'post_id' => $post_id ) ) as $comment ) {
$comment->comment_post_ID = $new_post_id;
wp_insert_comment( (array) $comment );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment