Moving WordPress comments

Edit: I wrote a plugin to make this easier, see the move WordPress comments plugin page.

Do you sometimes get comments that should be on a different post or page on your WordPress blog? I get such posts from time to time and always wondered how to move them to a different post. It turns out to be quite easy.

The information, on which post or page your comment resides, is stored in the wp_comments table of your blog database, in the comment_post_ID column. So use your favorite mysql client (like phpmyadmin) and change it.

If you don't know how to find the comment: you can get the comment's comment_ID in several ways, for example by hovering over the Edit comment link in your dashboard. To get the desired comment_post_ID you can use the same strategy and hover over the Edit post link.

I prefer to use the command line mysql client, and the plain SQL statement looks like

UPDATE wp_comments SET comment_post_ID=XXX WHERE comment_ID=YYY;

XXX is the ID of the page you want the comment to be on, YYY is the comment's ID. If in doubt, refer to the fine manual.By the way, if you want to fix the threading of a comment, my guess would be that you need to change the comment_parent to the parent comment's ID. I will update the post when I tried that.

Edit: You should also do this the following:

UPDATE wp_posts SET comment_count=comment_count+1 WHERE ID=XXX;
UPDATE wp_posts SET comment_count=comment_count-1 WHERE ID=YYY;

XXX is the target page, YYY is the page where the comment was before.


  1. avatar
    wrote this comment on

    So scary! Does that SQL command just send the comment straight to the other database thingy so that the comment moves to the correct post? Scary!

    How much SQL should I learn if I'm diving into Wordpress?

    Isn't there a wordpress "drop and drag" way to do this yet? Plugin?

    It seems that to learn wordpress and set up themes the way I want them I have to know XHTML, CSS, PHP, MYSQL, phpmyadmin... it just goes on and on! Is that true?

    I was thinking of being the 'site admin' for a group of activists in Australia. I backed out because it all seemed too hard... managing databases, setting up that extra community development, multi-user blog, and forum stuff. What if it broke, and needed a site admin with super-php or database powers? I'm at the stage where I'm just getting my head around basic CSS!

    Scary! Especially when BBpress is a whole new bit of software to know and style and add dozens of other plugin's to. Do you think BBpress will ever become a complete plugin, instead of a separate bit of software that requires dozens of plugins to work like most other forums do out of the box?


  2. avatar
    wrote this comment on

    You should have a look at <a href="" rel="nofollow">drupal</a>, it's better suited for multi-user &amp; community things than WordPress in my opinion.
    To be a WP admin you don't really need to know any HTML, CSS, PHP or SQL unless you want to new features to WP itself. Hence, try drupal.


Cancel reply
Markdown. Syntax highlighting with <code lang="php"><?php echo "Hello, world!"; ?></code> etc.
DjangoPythonBitcoinTuxDebianHTML5 badgeSaltStackUpset confused bugMoneyHackerUpset confused bugX.OrggitFirefoxWindowMakerBashIs it worth the time?i3 window managerWagtailContainerIrssiNginxSilenceUse a maskWorldInternet securityPianoFontGnuPGThunderbirdJenkinshome-assistant-logo