WordPress.org

Ready to get started?Download WordPress

Forums

Not importing comments from movabletype (18 posts)

  1. mfflynn
    Member
    Posted 8 years ago #

    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!

  2. mfflynn
    Member
    Posted 8 years ago #

    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.

  3. mfflynn
    Member
    Posted 8 years ago #

    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.

  4. cre8d
    Member
    Posted 8 years ago #

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

  5. cre8d
    Member
    Posted 8 years ago #

    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 :)

  6. jdcfsu
    Member
    Posted 8 years ago #

    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.

  7. djblurb
    Member
    Posted 8 years ago #

    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...

  8. cubex
    Member
    Posted 8 years ago #

    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

  9. hammerikaner
    Member
    Posted 8 years ago #

    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?

  10. djblurb
    Member
    Posted 8 years ago #

    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.

  11. Ryan Boren
    WordPress Dev
    Posted 8 years ago #

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

  12. Ryan Boren
    WordPress Dev
    Posted 8 years ago #

    <?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.";
    ?>

  13. Ryan Boren
    WordPress Dev
    Posted 8 years ago #

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

  14. Matt Mullenweg
    Troublemaker
    Posted 8 years ago #

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

  15. jbarse
    Member
    Posted 8 years ago #

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

  16. djblurb
    Member
    Posted 8 years ago #

    Lovely! Thanks for the resonse.

  17. JennyDC
    Member
    Posted 8 years ago #

    Can anybody help? I am dealing with exactly the reverse of this situation--I hope to migrate my posts from my spam-infested Movable Type 3.17 without importing the comments themselves. After a long period of neglect, I discovered belatedly that my server is not compatible with Blacklist (long story) and a ton of comments spam got through to MT (Ca. 22,000--around this time my MT quit letting me do bulk deletes!). My question is this--is there a way to execute the migration to WP that would leave off the old comments altogether? i.e., importing only the original content of the posts themselves?

    I am still new to the developer side of this stuff, so please bear with me, but I would really appreciate any help you can offer--I would hate to abandon the several months of posts that I have at the Movable Type blog just because it got too spammed to save.

  18. seldo
    Member
    Posted 8 years ago #

    Hi Jenny -

    I had the same problem as you and wrote a little PHP script that strips all the comments from the MT export file. Helped me get a 22MB export file down to 400k of actual posts, and WordPress handled it perfectly. Hope it works for you!

    My post about it is here:
    http://www.seldo.com/weblog/blogmonths/b200601.php#blog3408

Topic Closed

This topic has been closed to new replies.

About this Topic