Is it possible to move a comment that should be a reply to another comment?

I like to have a clean blog, and I also like that comments that are replies to other comments actually are replies to other comments. Some people don’t mind that difference too much and just leave another comment instead of a reply. That’s alright, but I’d like to fix it so that my blog stays clean and so that things are clearer to myself.

Is there a way that I can “move” a regular comment so that it becomes a reply to a certain comment instead?

Related posts

Leave a Reply

3 comments

  1. I use two plugins for moving comments, have used them on a site for moving over 1,000 comments to various posts (most of my commenter’s posted 90%+ comments on one popular post no matter what the comment was about!).

    http://www.dountsis.com/projects/move-comments/ : this allows you to move multiple comments in one go. This one is useful for moving entire threads from one post to another.

    The plugin recommended by pootzko : move one comment at a time including changing threading.

    Note: if you move a threaded comment with replies to another post and don’t move the replies as well it “breaks” the threading, you’ll find the child comments aren’t threaded correctly. So you have to move them all in a thread (or remove the threading on the child comments).

    David

  2. A alternative for custom source. I had read this answers, but the plugins are old or with to much options and I will leave my small solution.

    I never knew it’s that simple to copy all comments from one WordPress post to another. The following snippet copies all posts from $post_id to $new_post_id.

    <?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 );
    }
    

    get_comments() is a convenience function around WP_Comment_Query, so if you put this snippet inside a loop you can omit the ‘post_id’ parameter.

    Oh, and if you don’t need to copy but to move the comments, you may be better off by just firing some good old SQL against your database:

    <?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 );
    }