There have been several instances when my visitors comment on the wrong post, but I don’t blame them. Maybe it’s because of my note in the comment section that says “For non-post related comment, please visit my Guestbook”. But sometimes those comments meant for other posts like “Attic Cat Jung da Bin” and other 3-year-old posts are “misplaced” in the Guestbook page.
Finding a way to move the comments to their “rightful owner” or to the right post, I found a useful WordPress Tip: Move A Comment From A Post To Another article from Deluxe Blog Tips.
To be able to move the comments you need to know these 3 things first:
- comment’s ID – the ID of the comment you want to transfer
- source post’s ID – the ID of the post where the comment will be removed
- destination post’s ID – the ID of the post where the comment will be moved/transferred
To know the comment’s ID and the source post’s ID, go to the Edit Comments Page in your Admin Area and hover the mouse on the Approve/Unapproved link in the comments column. You will see the URL in the status bar. However if you’re using Chrome like me, you may not be able to see the full URL, so just right-click and copy the link address and paste it somewhere else, in a blank tab, notepad, etc.
You will see a link similar to this:
The comment’s ID is 12525 and the source post’s ID is 17, as indicated in p=171 and c=12525.
To know the destination post’s ID, go to the Edit Posts Page and move the mouse over the Post Title. You will see the URL in the status bar that is similar to this link:
Now we know that the destination post’s ID is 15, as seen from post=15.
Moving the comment using SQL
“I like to move it move it”
To move the comments you have to login to your site’s Control Panel and go to PHPMyAdmin to work with MySQL query. Although this is an easy task, use phpMyAdmin at your own risk. Be sure to backup your database too, to be on the safe side. 🙂
Choose your WordPress database, and click on the SQL tab.
Now, we’re going to use these SQL snippets
UPDATE wp_comments SET comment_post_ID=destination's post ID WHERE comment_ID=comment's ID; UPDATE wp_posts SET comment_count=comment_count+1 WHERE ID=destination's post ID; UPDATE wp_posts SET comment_count=comment_count-1 WHERE ID=source post's ID;
Type the following queries in the SQL tab and press Go, but be sure to replace it with your own comment and post IDs.
UPDATE wp_comments SET comment_post_ID=15 WHERE comment_ID=12570; UPDATE wp_posts SET comment_count=comment_count+1 WHERE ID=15; UPDATE wp_posts SET comment_count=comment_count-1 WHERE ID=171;
WordPress will not automatically fix the comment count that’s why we have to add 1 to the destination post and delete one from the source post.
If your WordPress Database Table prefix is not wp_, (such as
wp_posts), replace wp_ with the prefix you're using.
If you did as instructed above, you will see this message:
Refresh the Comments Page and you will see that the comment has been moved to the other post.
I try not to use plugin if I can do it myself, but for those who prefer to use a plugin you can use