migrating comments between wordpress installations

Posted on 2011-10-30
Last Modified: 2012-05-12
I've been working on migrating comments from an old WP install to a new one. The tricky part is that the on new install, the post ID's are different. I've written a script to match up the correct post ID's, but how do I insert them?

I need to give them unique commend_ID's. Is there a function in mysql to insert the highest unique number? Or should I just find the highest value via PHP and increment upon each insertion?

Will I need to do anything to generate commentmeta?
Question by:SonicVoom
    LVL 21

    Expert Comment

    LVL 31

    Accepted Solution

    You probably want to use a native WordPress function for this


    or wp_new_comment()

    You can see what those functions do in comment.php:
    LVL 2

    Author Closing Comment

    yep, wp_insert_comment() did the trick.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
    These days socially coordinated efforts have turned into a critical requirement for enterprises.
    The purpose of this video is to demonstrate how to update a WordPress Site’s version. WordPress releases new versions of its software frequently and it is important to update frequently in order to keep your site secure, and to get new WordPress…
    The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now