Sometimes we meet the situation when someone asks about something by leaving a comment in a post, but the question is very different from the post content. For example: ask about SEO in a post that writes about CSS3, ask about WordPress in a post that writes about Blogger, etc. This comment adds nothing to discussion about the post content, and other commentators don't like that. In this article, I'll show you a small tip that move a comment from a post to another using MySQL query without any plugins.
Define Comment's ID, Source Post's ID And Destination Post's ID
First, we need to define the comment's ID, source post's ID and destination post's ID. To define the comment's ID and source post's ID, go to the Comments page, move mouse over a Approve/Unapprove link under comment's content, you'll see the URL in the browser's status bar, it looks like this:
http://localhost/wp/wp-admin/comment.php?action=unapprovecomment&p=158&c=91&_wpnonce=d4e3a3b4f5
Notice the p=158
and c=91
parameters. Here 91 is the comment's ID and 158 is the source post's ID.
To define the destination post's ID, just go to the Posts menu, move mouse over the Edit link under post , you'll see the URL in the browser's status bar, it looks like this:
http://localhost/wp/wp-admin/post.php?post=127&action=edit
Notice the post=127
parameter, here 127 is the post's ID.
Move Comment Using PhpMyAdmin
Now we'll use PhpMyAdmin to work with MySQL query. If you're not familiar with PhpMyAdmin, or if this is the first time you work with raw MySQL query, don't worry, it's easy to use.
To start PhpMyAdmin, just go to your host control panel and launch it. Then choose your WordPress database, and click on the SQL tab. You'll see a screen like this:
In the blank field, type the following SQL command:
UPDATE wp_comments SET comment_post_ID=127 WHERE comment_ID=91; UPDATE wp_posts SET comment_count=comment_count+1 WHERE ID=127; UPDATE wp_posts SET comment_count=comment_count-1 WHERE ID=158;
Remember to change 91 to your comment's ID, 158 to your source post's ID, 127 to your destination post's ID. If you use another prefix for WordPress tables, you should change the tables' names (wp_comments
, wp_posts
) to correct values.
After all, press the Go button. If everything is right, you'll get the successful message: "Your SQL query has been executed successfully". Now, go back to Comments page in WordPress Dashboard, you'll see your comment has been moved to new post.
Moving comments is unusual operation, but sometimes it's needed. I hope this post will help you a bit when dealing with comments without plugins.
Leave a Reply