WordPress tip: Move comments from one post to another post
Posted: January 31, 2009 | Author: hilary | Filed under: blog | Tags: tips, wordpress | 3 Comments »I recently ended up with two posts on this site about the same project — one was a short summary, and the other a long, detailed article. I decided to consolidate them into the longer article, but I didn’t want to lose the six comments that had been posted to the short article.
I couldn’t find a way in the WordPress UI to move comments from one post to another, so I jumped into the database. If you run WordPress on a host, they probably provide a MySQL management tool like PHPMyAdmin, or you can log in with a mysql client.
First, find the table that contains the posts for your blog (the table name usually ends in _posts). Find the ID that matches the post you want to move comments from, and the ID for the post that you want to move comments to.
Note: An easy way to do this is to search by the post title. If you need to write the SQL by hand, use something like this:
SELECT * FROM wp_posts WHERE post_title LIKE '%posttitlekeyword%';
Replace wp_posts with the name of the database table containing your posts, and posttitlekeyword with a relatively unique keyword or phrase from the title of your post.
Second, switch to the comments table. Each comment is linked to a particular post by the ID in the comment_post_ID field. You want to switch all of the entries that point to the ID for the first post to the ID for the second post. You can do this in a visual interface by searching for the relevant comments and updating them one by one, or using this SQL:
UPDATE wp_comments SET comment_post_id=2 WHERE comment_post_id=1;
Change 1 to the ID of the original post and 2 to the ID of the post you want to move the comments to.
Note: You are making changes to your WordPress database! If things go awry, you could lose your data. Make sure you have a robust backup strategy before you attempt to change anything.
-
http://chrishempel.com chris hempel
-
april
-
çiçekçi


