There are two ways that can make this happen. Each one has its advantages ant disadvantages as outlined below:
- By directly manipulating the WordPress database. This is the quickest and most professional way, but running SQL statements is not everyone’s cup of tea.
- The second way is not actually about moving the comments, but rather about moving the post itself out of its comments. This is the simplest of the ways and requires zero knowledge of SQL.
Both ways are very safe.
The SQL Way
First of all, create a new post as usual and add any amount of content in it. What you will do is to attach the comments from the old page to the new one.
You will need to know the IDs of your new and old posts. It might not be possible to determine the post ID from the post’s URL as it might not be included in the permalink structure you use. In that case, examine the hyperlinks of the posts in question under the “Manage menu” in the WordPress administration panel.
In the following SQL queries, substitute OLD_ID and NEW_ID according to your posts’ IDs.
Transfer the comments with the following statement:
UPDATE wp_comments SET comment_post_ID=NEW_ID WHERE comment_post_ID=OLD_ID;
That’s it. The comments have been transfered, but we are not done yet.
WordPress keeps the number of each post’s comments hard-coded into the post’s record. This probably serves as a performance booster, but it is necessary to take care of it as well.
Run the following query and take a note of the number in the output. This represents the number of comments under the old post.
SELECT comment_count FROM wp_posts WHERE ID=OLD_ID;
Assume that the numeric result is COMCOUNT.
Then adjust the hardcoded number of comments under the two posts by substituting COMCOUNT, NEW_ID, OLD_ID in the following statements as appropriate:
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;
You are set.
The WordPress Way
This is called the “WordPress way” because everything takes place within the WordPress administration panel. The general idea is to create a new post identical to the old one and change the old post, which actually has the comments, appropriately so that it is considered as a new post by WordPress.
- First of all, create the new post and add content as appropriate.
- Second and most important, take a good note of the old post’s “Title“, “Post Slug” and “Post Timestamp“.
- Edit the old post‘s “Title“, “Post Slug” and “Post Timestamp” (make sure the “Edit timestamp” checkbox is checked) to some new values and save it.
- Edit the new post‘s “Title“, “Post Slug” and “Post Timestamp” to the exact values of the old post (remember the note you had taken?) and publish it.
This is not a task WordPress users have to accomplish everyday. But, when there is need for it, you will know how to do it. Both ways are safe and complete. Use the one that suits you better.
Move comments to another post in WordPress by George Notaras is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Copyright © 2007 - Some Rights Reserved