I recently created a new WP site with some of the same content from my old WP site.
Is there a way to migrate comments from my old database to me new database? i tried importing old the wp_comments
table into my new db via phpmysql. They did import and appeared in my wp admin, but they weren’t associated with the correct posts and categories. Looking at the .sql
file I’m guessing that this didn’t work because the old comments all have different comment_post_IDs
from my new db.
Is there a way around this or another way to migrate the old comments?
You could export all of the posts from your old site, including comments. Then, import them into your new site and delete the posts you don’t want. This will preserve all of the links between posts and comments.
I see at least 3 solutions:
install old version of wordpress on a development machine, import your database and change settings from
wp-config
to use the database you imported; Then export anything you want;If you saved the old
ids
in `wp_postmeta you can make a script that do this:If there aren’t too many posts, you could manually update
wp_comments
(import your database and using PhpMyAdmin, see what is the old id of every post, see what is the new id in your newly wordpress install and run this queryUPDATE wp_comments SET comment_post_ID = new_id WHERE comment_post_ID = old_id;
)