abinidi 1 Posted May 11, 2005 Share Posted May 11, 2005 I decided to give WordPress a try, and I followed the TCH instructions to install it (working fine), and I followed the following instructions to migrate my blogger.com content into my new WP blog. The entries (over 100) all imported fine, but for some reason, I didn't get ANY comments. Does anybody have a suggestion about what I did wrong? Can I reimport the content without causing duplicate entries, or do I need to clear the database first? Thanks, Paul Quote Link to post Share on other sites
abinidi 1 Posted May 11, 2005 Author Share Posted May 11, 2005 When I look at the files exported by blogger, there are no comments (which is why wordpress can't find them...) So I've localized the problem to blogger. I'm not doing something right so that the comments will get exported. Any suggestions?? (Dang... Blogger has a scheduled down time at 16:00 PT today. Just my luck!! ) Quote Link to post Share on other sites
abinidi 1 Posted May 11, 2005 Author Share Posted May 11, 2005 I'm working through this right now, and I'll post more instructions about it later (once I've got it working), but I thought I'd give an update on what I've found: The instructions on the /wp-admin/import-blogger.php page (in the wordpress zip file) are incomplete. What I *think* you have to do is this: Go to the following page: http://www.skeltoac.com/import-blogger.php.txt Copy and paste the text from that page into a text file. save the file as import-blogger.php Upload the file to /wp-admin/ in your blog directory now run http/yoursite/blogdirectory/wp-admin/import-blogger.php The correct instructions will now be included, and comments will be imported. I will verify if this works, and will post to the forums (probably tomorrow, because Blogger is down right now, so I can't re-export my file). Quote Link to post Share on other sites
TCH-Bruce 16 Posted May 12, 2005 Share Posted May 12, 2005 Sorry, don't know Paul. I migrated to WP from MT. When I migrated to MT from Blogger I lost all my comments because they were at HaloScan. Quote Link to post Share on other sites
jwbowden 0 Posted May 12, 2005 Share Posted May 12, 2005 Thanks for taking the time to document this for us. I'd been considering trying Wordpress also (I'm an MT user). I have confirmed that MT exports the comments with the entries in MT 3.x I look forward to more info. Don't forget to tell us what you think of Wordpress once you get going! Quote Link to post Share on other sites
TCH-Bruce 16 Posted May 12, 2005 Share Posted May 12, 2005 When I migrated from MT to WP it worked flawlessly. All comment came over without a hitch. If you follow these instructions it works just great. Quote Link to post Share on other sites
abinidi 1 Posted August 9, 2005 Author Share Posted August 9, 2005 Ok. So months later I realized that I never included the more detailed instructions that I promised here -- so here they are: Converting from Blogger to WordPress 1.5.1 TotalChoice users who want to install WordPress 1.5.1, can use the instructions located here to install WordPress. These directions are great. Once you get WordPress installed, you are going to want to import all of your Blogger posts and comments. The built-in importer does not import your Blogger comments automatically. The steps below will help you import both your Blogger posts and your Blogger comments. You should note that this script will import comments EVEN IF you have already imported your posts previously. When I did it, I found that about 10% of my posts were duplicated, so use at your own risk. 1. Install WordPress using the instructions linked to above. These instructions have five major steps with sub-steps for each major step. You should complete all five major steps before continuing with the process outlined below. 2. Copy the code in the code box below, and paste it into a text editor. ><?php $wpvarstoreset = array('action'); for ($i=0; $i<count($wpvarstoreset); $i += 1) { $wpvar = $wpvarstoreset[$i]; if (!isset($$wpvar)) { if (empty($_POST["$wpvar"])) { if (empty($_GET["$wpvar"])) { $$wpvar = ''; } else { $$wpvar = $_GET["$wpvar"]; } } else { $$wpvar = $_POST["$wpvar"]; } } } require_once('../wp-config.php'); require('upgrade-functions.php'); switch ($action) { case "step1": ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <title>Blogger to WordPress - Converting...</title> <link rel="stylesheet" href="wp-admin.css" type="text/css"> </head> <body> <div class="wrap"> <h1>Blogger to <img src="../wp-images/wpminilogo.png" width="50" height="50" border="0" alt="WordPress" align="top" /></h1> <p>The importer is running...</p> <ul> <li>Importing posts and users <ul><?php for($bgy=1999; $bgy<=(date('Y')); $bgy++) { for($bgm=1; $bgm<13; $bgm++) { $bgmm = zeroise($bgm,2); $archivefile = "../$bgy"."_"."$bgmm"."_01_wordpress.php"; if (file_exists($archivefile)) { $postcount = 0; $skippedpostcount = 0; $commentcount = 0; $skippedcommentcount = 0; $f = fopen($archivefile,"r"); $archive = fread($f, filesize($archivefile)); fclose($f); echo "<li>$bgy/$bgmm "; $posts = explode('<wordpresspost>', $archive); for ($i = 1; $i < count($posts); $i = $i + 1) { $postparts = explode('<wordpresscomment>', $posts[$i]); $postinfo = explode('|||', $postparts[0]); $post_date = $postinfo[0]; $post_content = $postinfo[2]; // Don't try to re-use the original numbers // because the new, longer numbers are too // big to handle as ints. //$post_number = $postinfo[3]; $post_title = $postinfo[4]; $post_author = trim(addslashes($postinfo[1])); // we'll check the author is registered already $user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE user_login = '$post_author'"); if (!$user) { // seems s/he's not, so let's register $user_ip = '127.0.0.1'; $user_domain = 'localhost'; $user_browser = 'server'; $user_joindate = '1979-06-06 00:41:00'; // that's my birthdate (gmt+1) - I could choose any other date. You could change the date too. Just remember the year must be >=1970 or the world would just randomly fall on your head (everything might look fine, and then blam! major headache!) $user_login = addslashes($post_author); $pass1 = addslashes('password'); $user_nickname = addslashes($post_author); $user_email = addslashes('user@wordpress.org'); $user_url = addslashes(''); $user_joindate = addslashes($user_joindate); $result = $wpdb->query(" INSERT INTO $wpdb->users ( user_login, user_pass, user_nickname, user_email, user_url, user_ip, user_domain, user_browser, user_registered, user_level, user_idmode ) VALUES ( '$user_login', '$pass1', '$user_nickname', '$user_email', '$user_url', '$user_ip', '$user_domain', '$user_browser', '$user_joindate', '1', 'nickname' )"); echo ": Registered user <strong>$user_login</strong>"; } $post_author_ID = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_login = '$post_author'"); $post_date = explode(' ', $post_date); $post_date_Ymd = explode('/', $post_date[0]); $postyear = $post_date_Ymd[2]; $postmonth = zeroise($post_date_Ymd[0], 2); $postday = zeroise($post_date_Ymd[1], 2); $post_date_His = explode(':', $post_date[1]); $posthour = zeroise($post_date_His[0], 2); $postminute = zeroise($post_date_His[1], 2); $postsecond = zeroise($post_date_His[2], 2); if (($post_date[2] == 'PM') && ($posthour != '12')) $posthour = $posthour + 12; else if (($post_date[2] == 'AM') && ($posthour == '12')) $posthour = '00'; $post_date = "$postyear-$postmonth-$postday $posthour:$postminute:$postsecond"; $post_content = addslashes($post_content); $post_content = str_replace('<br>', '<br />', $post_content); // the XHTML touch...;) $post_title = addslashes($post_title); // Quick-n-dirty check for dups: $dupcheck = $wpdb->get_results("SELECT ID,post_date,post_title FROM $wpdb->posts WHERE post_date='$post_date' AND post_title='$post_title' LIMIT 1",ARRAY_A); if ($dupcheck[0]['ID']) { $skippedpostcount++; $comment_post_ID = $dupcheck[0]['ID']; } else { $result = $wpdb->query(" INSERT INTO $wpdb->posts (post_author,post_date,post_content,post_title,post_category) VALUES ('$post_author_ID','$post_date','$post_content','$post_title','1') "); $comment_post_ID = $wpdb->get_var("SELECT MAX(ID) FROM $wpdb->posts"); } if ($postparts[1]) { for ($j = 1; $j < count($postparts); $j = $j + 1) { $commentinfo = explode('|||', $postparts[$j]); $comment_date = explode(' ', $commentinfo[0]); $comment_date_Ymd = explode('/', $comment_date[0]); $commentyear = $comment_date_Ymd[2]; $commentmonth = zeroise($comment_date_Ymd[0], 2); $commentday = zeroise($comment_date_Ymd[1], 2); $comment_date_His = explode(':', $comment_date[1]); $commenthour = zeroise($comment_date_His[0], 2); $commentminute = zeroise($comment_date_His[1], 2); $commentsecond = '00'; if (($comment_date[2] == 'PM') && ($commenthour != '12')) $commenthour = $commenthour + 12; else if (($comment_date[2] == 'AM') && ($commenthour == '12')) $commenthour = '00'; $comment_date = "$commentyear-$commentmonth-$commentday $commenthour:$commentminute:$commentsecond"; $comment_author = addslashes(strip_tags(html_entity_decode($commentinfo[1]))); // Believe it or not, Blogger allows a user to call himself "Mr. Hell's Kitchen" which, as a string, really confuses SQL. if ( strpos($commentinfo[1], 'a href') ) { $comment_author_parts = explode('"', htmlentities($commentinfo[1])); $comment_author_url = $comment_author_parts[1]; } else $comment_author_url = ''; $comment_content = addslashes($commentinfo[2]); $comment_content = str_replace('<br>', '<br />', $comment_content); $dupcheck = $wpdb->get_results("SELECT comment_ID,comment_post_ID, comment_author, comment_date, comment_content FROM $wpdb->comments WHERE comment_post_ID='$comment_post_ID' AND comment_author='$comment_author' AND comment_date='$comment_date' AND comment_content='$comment_content' LIMIT 1",ARRAY_A); if ( $dupcheck[0]['comment_ID'] ) { $skippedcommentcount++; } else { $result = $wpdb->query(" INSERT INTO $wpdb->comments (comment_post_ID,comment_author,comment_author_url,comment_date,comment_content) VALUES ('$comment_post_ID','$comment_author','$comment_author_url','$comment_date','$comment_content') "); } $commentcount++; // Increment the monthly comment counter } // End of comment processing loop } // End of comment tester $postcount++; } // End of post processing loop echo "... $postcount post(s) parsed, $skippedpostcount skipped... $commentcount comment(s) parsed, $skippedcommentcount skipped... <strong>Done</strong></li>"; } // End of monthly archive processor } // End of monthly loop } // End of yearly loop upgrade_all(); ?> </ul> <strong>Done</strong> </li> </ul> <p> </p> <p>Completed Blogger to WordPress import!</p> <p><strong>Cleanup steps:</strong><br />Delete everything that Blogger put on your web server. Files like '2005_01_01_wordpress.php' just take up space and folders like '2005' can mess up your WordPress archives, so delete them.</p> <p>Now you can go and <a href="../wp-login.php">log in</a>, have fun!</p> </div> </body> </html> <?php break; default: ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <title>Blogger to WordPress Import Utility</title> <link rel="stylesheet" href="wp-admin.css" type="text/css"> </head> <body> <div class="wrap"> <h1>Blogger to <img src="../wp-images/wpminilogo.png" width="50" height="50" border="0" alt="WordPress" align="top" /></h1> <p>This is a complete Blogger to WordPress import script.</p> <p>What it does:</p> <ul> <li>Parses your Blogger archives to retrieve your posts and comments.</li> <li>Adds an author whenever it sees a new nickname, all authors are imported at level 1, with a default profile and the password 'password'</li> </ul> <p>What it does not:</p> <ul> <li>It isn't very forgiving. <li>It sucks at making coffee.</li> <li>It always forgets to call back.</li> </ul> <h2>Follow these directions exactly, or else! You have been warned. :)</h2> <h3>First step: Install WordPress</h3> <p>Install the WordPress blog as explained in the <a href="../readme.html">read me</a>, then immediately come back here.</p> <h3>Second step: let's play with Blogger</h3> <ul><li>Log into your Blogger account. Go to Settings.</li> <li>In the Publishing tab, have Blogger publish your files in the directory where your WordPress resides. Save Settings.</li> <li>In the Formatting tab, set Timestamp Format to mm/dd/yyyy hh:mm:ss AM/PM (the first choice in the dropdown menu). Save Settings.</li> <li>In the Comments tab, set the Comments Timestamp Format just like you did in the previous step. Save Settings.</li> <li>In the Archives tab, set the frequency to 'monthly' and the archive filename to 'wordpress.php' (without the quotes), set the ftp archive path to make Blogger publish the archives in your WordPress directory. Save Settings.</li> <li>Go to your Template. Replace your existing template with this very long line (copy and paste, don't break it into lines): <code><Blogger><wordpresspost><$BlogItemDateTime$>|||<$BlogItemAuthorNickname$>|||<$BlogItemBody$>|||<$BlogItemNumber$>|||<$BlogItemSubject$><BlogItemCommentsEnabled><BlogItemComments><wordpresscomment><$BlogCommentDateTime$>|||<$BlogCommentAuthor$>|||<$BlogCommentBody$></BlogItemComments></BlogItemCommentsEnabled></Blogger></code> Save Template Changes.</li> <li>Click 'Republish'. If you republish Index Only, it will not work. Sorry, you have to wait while Blogger does its thing.</li> <li>Check in your FTP that you've got the archive files published. They should look like this example: <code>2005_03_01_wordpress.php</code>. If they aren't there, redo the republish process.</li> </ul><p>You're done with the hard part. :)</p> <form name="stepOne" method="get"> <input type="hidden" name="action" value="step1" /> <h3>Third step: w00t, let's click OK:</h3> <p>When you're ready, click OK to start importing: <input type="submit" name="submit" value="OK" /><br /><br /> <i><strong>Note:</strong> the script might take some time, like 2 seconds for every 100 entries (posts and comments) imported. DO NOT STOP IT or else you won't have a complete import.</i></p> </form> </div> </body> </html> <?php break; } ?> 3. Save the file as "import-blogger.php". 4. Upload the import-blogger.php file to the /wp-admin/ folder in your blog's directory structure. If you are using cPanel's file manager to upload the file, be sure to check the "replace file(s)" checkbox. This will allow the file to replace the default (defective) file. 5. Run the file in your web browser. For example, if your blog is located at: example.com/blog, use the following url: example.com/blog/wp-admin/import-blogger.php. If your blog is located at blog.example.com, use the following url: blog.example.com/wp-admin/import-blogger.php. 6. More instructions will be displayed on the screen. Follow those instructions. The import-blogger.php file was modified by Andy Skelton. He includes more information (including troubleshooting information) in this blog entry. Happy WordPressing!! Quote Link to post Share on other sites
TCH-Bruce 16 Posted August 9, 2005 Share Posted August 9, 2005 Thanks Paul for the info. I'm sure some of our users will benefit from it. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.