Move a comment to another post

October 21, 2008 · Print This Article

Even if this is quite rare, it happen sometimes that someone leave a comment on a post instead of another one. In that case, it is possible to move the comment by using phpmyadmin and sql.

First of it all, login to your phpmyadmin and choose your WordPress database. Once done, click on the sql button to open the sql command window.

Now, we have to get the ID of each post. Once you have it, run the following command on the SQL window:
UPDATE wp_comments SET comment_post_ID=NEW_ID WHERE comment_post_ID=OLD_ID;
Right now, the comments are moved, but we need some extra queries to finish the job: WordPress tracks the number of comments per posts.

The following query will give you the number of comments under the old post:
SELECT comment_count FROM wp_posts WHERE ID=OLD_ID;
We have to run theses two last SQL commands to finish the job. COMCOUNT is the number we get with the previous query.
UPDATE wp_posts SET comment_count=comment_count+COMCOUNT WHERE ID=NEW_ID;
UPDATE wp_posts SET comment_count=comment_count-COMCOUNT WHERE ID=OLD_ID;

Right now, all comments from a post have been successfully moved to another post.

Your choice for site templates and wordpress themes


Got something to say?

You must be logged in to post a comment.