Skip to content

Instantly share code, notes, and snippets.

@eteubert
Created March 3, 2013 20:28
Show Gist options
  • Select an option

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

Select an option

Save eteubert/5078138 to your computer and use it in GitHub Desktop.
WordPress: move comments between posts
<?php
function move_comments( $from_post_id, $to_post_id ) {
global $wpdb;
$sql = sprintf(
'UPDATE %s SET comment_post_id=%s WHERE comment_post_id=%s;',
$wpdb->comments,
(int) $to_post_id,
(int) $from_post_id
);
$wpdb->query( $sql );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment