{"id":781,"date":"2012-07-13T23:42:10","date_gmt":"2012-07-14T06:42:10","guid":{"rendered":"http:\/\/jim-zimmerman.com\/?p=781"},"modified":"2012-07-13T23:42:10","modified_gmt":"2012-07-14T06:42:10","slug":"how-to-move-wordpress-comments-using-mysql","status":"publish","type":"post","link":"https:\/\/jim-zimmerman.com\/?p=781","title":{"rendered":"How to move WordPress comments using MySQL."},"content":{"rendered":"<p>Used the following method to move comments in WordPress 3.<\/p>\n<p>Key information needed:  <\/p>\n<p>Determine the post ID (comment_post_ID) for where the comment was made.  You can determine this from the WordPress Dashboard.  In this post, (http:\/\/jim-zimmerman.com\/?p=781) 781 is the comment_post_ID.<\/p>\n<p>Determine the post ID (comment_post_ID)for where the comment should go.  <\/p>\n<p>Determine the comment ID (comment_ID).   There are many ways you could determine this, but you should probably choose something unique to the comment like the comment_author_email that you should be able to get from the comment.  <\/p>\n<p>Move the comment:<\/p>\n<p>mysql> UPDATE wp_comments SET comment_post_id=&#8221;<em>newcommentpostid<\/em>&#8221; WHERE comment_post_ID=&#8221;<em>oldcommentpostid<\/em>&#8221; AND comment_author_email=&#8221;<em>commentauthoremail<\/em>&#8220;;<\/p>\n<p>Determine the number of comments where the post has moved to:<\/p>\n<p>mysql> SELECT COUNT(*) FROM wp_comments WHERE comment_post_id=&#8221;<em>newcommentpostid<\/em>&#8220;;<\/p>\n<p>Determine the updated number of comments for the post where the comment was originally made:<\/p>\n<p>mysql> SELECT COUNT(*) FROM wp_comments WHERE comment_post_id=&#8221;<em>oldcommentpostid<\/em>&#8220;;<\/p>\n<p>Update the counts for each of the posts:<\/p>\n<p>mysql> UPDATE wp_posts SET comment_count=&#8221;<em>newcommentcountwhereadded<\/em>&#8221; WHERE id=&#8221;<em>newpostid<\/em>&#8220;;<\/p>\n<p>mysql> UPDATE wp_posts SET comment_count=&#8221;<em>newcommentcountwhereremoved<\/em>&#8221; WHERE id=&#8221;<em>oldpostid<\/em>&#8220;;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Used the following method to move comments in WordPress 3. Key information needed: Determine the post ID (comment_post_ID) for where the comment was made. You can determine this from the WordPress Dashboard. In this post, (http:\/\/jim-zimmerman.com\/?p=781) 781 is the comment_post_ID. Determine the post ID (comment_post_ID)for where the comment should go. Determine the comment ID (comment_ID). [&#038;hellip<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[288,248,287],"class_list":["post-781","post","type-post","status-publish","format-standard","hentry","category-documentation","tag-move-comments","tag-mysql","tag-wordpress"],"share_on_mastodon":{"url":"","error":""},"_links":{"self":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts\/781","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=781"}],"version-history":[{"count":1,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts\/781\/revisions"}],"predecessor-version":[{"id":782,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts\/781\/revisions\/782"}],"wp:attachment":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=781"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=781"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=781"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}