WordPress.org

Support

Support » How-To and Troubleshooting » Not importing comments from movabletype

Not importing comments from movabletype

  • I just installed wordpress and I ran the mt import script from the admin on the exported text file from movable type v 3.2 and all the entries seemed to have imported fine, but none of the comments came over.

    I double checked and the comments are in the exported mt file, so what happened? Help!

Viewing 15 replies - 1 through 15 (of 17 total)
  • Slight change: Upon inspecting the tables in the wp database, the comments seem to be in there, but they are not associated with any of the articles.

    i.e. I have an article with 12 comments, they seem to be in the comments table, yet when you go to that articles archive page, it shows it as having 0 comments.

    Looks like the “comment_count” field is not getting updated in the import process.

    Unless anyone has any solutions, I’ll assume this a bug, and I’ll write a little script to update all the “comment_count” fields.

    mfflynn, that would be awesome. Please let us know if you get some code we can use.

    Working on this code…

    1. UPDATE wp_comments set comment_approved = 1

    2. CREATE TABLE mytemp SELECT count(*) as numberofcomments, comment_post_ID as post FROM wp_comments group by comment_post_ID order by comment_post_ID

    3. UPDATE wp_posts,mytemp SET wp_posts.comment_count = mytemp.numberofcomments WHERE wp_posts.ID=mytemp.post;

    but there’s a bug in the MySQL for #3… any help appreciated 🙂

    This doesn’t exactly fix the importer but this worked for me. I took your first line “UPDATE wp_comments set comment_approved = 1” and ran it and for some reason it set all of my comment_approved fields to “0”. This is ok though because that put all of the comments up for moderation and with a simple “Approve All” command all of my comments showed up. Hope it helps someone else.

    What if you have a lot of comments? Like 10s of thousands? I have the “lost comment” problem as well.

    Not a big incentive to migrate from MT…

    Here’s a shamless self-plug guys. I faced the exact same problem with the comments, please use this patch to fix it:

    http://wordpress.org/support/topic/53543

    I’m a bit new here, folks. I want to move to WP 2.0 from WP 3.x, and my comments didn’t get imported… how do I apply this patch?

    Cubex, are you saying you have to reimport all the entries from MT?

    PAIN.

    I was hoping to evaluate WP 2 with a very very large MT database and it took forever to import. This issue has really soured my WP experience.

    I’ll provide a script to fix your DB, but I’m traveling right now so it might take a day.

    <?php
    require_once('admin.php');
    echo "Approving comments...";
    // Approve all comments
    $wpdb->query("UPDATE $wpdb->comments SET comment_approved = '1'");
    echo "Updating post counts...";
    // Populate comment_count field of posts table
    $comments = $wpdb->get_results( "SELECT comment_post_ID, COUNT(*) as c FROM $wpdb->comments WHERE comment_approved = '1' GROUP BY comment_post_ID" );
    if( is_array( $comments ) ) {
    foreach ($comments as $comment) {
    $wpdb->query( "UPDATE $wpdb->posts SET comment_count = $comment->c WHERE ID = '$comment->comment_post_ID'" );
    }
    }
    echo "Done.";
    ?>

    Stick that in a file (say fix_mt_import.php) in wp-admin and load it.

    Nice job Ryan. I forum ate some of the code, I fixed the formatting.

    Thanks, Ryan, that really helps my migration to WP, too…

    Lovely! Thanks for the resonse.

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Not importing comments from movabletype’ is closed to new replies.
Skip to toolbar