How to Move Comments in WordPress 3.0 with phpMyAdmin

Many of the Move Comments plugins for WordPress do not seem to work properly in WordPress 3.0, so I needed a way to move comments around from one post/page to another, as well as retain any threaded/nested comments. One could always move comments by modifying the database directly with phpMyAdmin or something similar, and this is what I had to resort to. Modifying your WordPress database directly isn’t something you want to do every day, but sometimes it is completely unavoidable. It took me all of 5 minutes to figure this out, so it shouldn’t be too difficult for you either.

Warning – backup your database now! You should always take precautions when modifying the database directly because you can really mess up WordPress if you do something wrong. You are highly advised to make a backup before proceeding, especially if you don’t feel comfortable with these instructions. Also, it’s a good idea to backup just in case these instructions become obsolete or outdated!

Assuming you’ve backed up your database, let’s continue!

Open up phpMyAdmin and click the wp_comments link on the left hand side:

PIC: screenshot 01

Now you’ll see a page with a ton of information about the wp_comments table, which is a table in your WordPress database that contains all of the comments.

Scroll down the page until you locate the section that says Run SQL query/queries on database:

PIC: screenshot 02

Pictured above is a SQL query that basically means “retrieve all comment records from the wp_comments table.”

Click the Go button to run this SQL query and retrieve the records from the database.

When the comment records have been retrieved, you will be presented with another page that shows a list of all the comments that are stored in the wp_comments table. This is where you can edit a comment to move it somewhere else.

You’ll want to locate the comment record that you wish to move, click the edit button, then modify the comment_post_ID value and/or comment_parent value to effectively assign the comment to a different post, page, or parent comment. If you’ve selected the option to Enable threaded (nested) comments under Settings –> Discussion, comment_parent is what relates child comments to parent comments so they can appear nested.

In the screenshot below, comment 122 appears nested beneath comment 120 in post 21 due to the relationship defined in comment_parent for comment 122.

PIC: screenshot 03

Hold up cowboy, you aren’t done yet! If you were to visit the actual post/page where you moved the comment to, you would notice that the Comment Count hasn’t been updated even though the comments now appear to be moved and show up on the post/page.

What you’ll need to do now is modify the post/page record, much in the same way that you modified the comment record, but instead you would select the wp_posts link on the left hand side of phpMyAdmin. Again, you’ll want to query the table, then locate the post/page that needs the Comment Count updated.

This is where things might get confusing and here’s why: WordPress stores every revision that you make to a page/post, not just the current copy, so you’ll want to locate the most recent revision (the one that is actually being displayed on your blog) and modify THAT record only. It’s easy to locate the most recent revision, just check the post_type column for “page” or “post” and not “revision”.

Once you locate the correct record, edit the record and update the comment_count value to match how many comments you actually have for that post/page.

You’re done!

Related

Tags: , , ,

1 Comment

  1. Thank you, thank you, thank you! This was exactly what I needed. I was able to move 34 comments and update the comment tally perfectly, in a minimum amount of time by following your instructions. Again, THANKS!

    Tamara

Leave a Reply

Your email address will not be published. Required fields are marked *