Moving from WordPress to Movable Type part 1

| 18 Comments

**Update**: This code is now maintained at my new software projects blog, located here.

You'll see a lot of articles out there telling people how to switch from Movable Type to WordPress, but there's not a lot about people switching from WordPress to Movable Type. I aim to correct that, by starting out with a tutorial on how to get your blog data exported from WordPress, and then ending eventually with discussion on how to get your blog looking mostly like how it looked with WordPress so there is a minimum amount of disruption.

Run this PHP script in your WordPress directory. Your directory structure should look something like this:

/
--->wp-config.php
--->wp-export-mt.php
--->wp-includes/
--->wp-includes/wp-db.php

That script will generate a bunch of text that you will need to copy and paste into a decent text editor like TextPad. Save it as ANSI text and use Unix file encoding. Movable Type doesn't really seem to like a whole lot else besides that when importing. Believe me, I used the WPExport plugin that you can find on Google and I spent more time trying to coaxe the import feature into working than actually rewriting my template. Movable Type's import mechanism can be very finicky.

Once you have saved the file, put it into the import directory under your Movable Type administration console's directory on the webserver. The name doesn't matter, as the import mechanism will try to import from any file that is in that directory. Note: Movable Type will allow you to import the same entries over and over again. Its import mechanism is not intelligent in that respect. It is up to you to make sure that you don't duplicate posts.

Now, click on the rebuild action item at the bottom of the tool bar in Movable Type and rebuild everything. If you don't, you won't have any of that imported availible to others. If the import failed, or screwed up royally, and you are using a MySQL database, you can use the following commands to reset things back to the way they were:

delete from mt_entry;
delete from mt_comment;
delete from mt_category;
delete from mt_placement;
delete from mt_trackback;

alter table mt_entry auto_increment = 0;
alter table mt_comment auto_increment = 0;
alter table mt_category auto_increment = 0;
alter table mt_placement auto_increment = 0;
alter table mt_trackback auto_increment = 0;

You will obviously have to follow your host's instructions for how to log into your MySQL database, but you can just copy and paste these commands in. They, will, however, cheerfully delete everything in those tables, so be careful about when you choose to use them.

So, at this point you shouldn't have any problem with actually getting your entries moved over. The next step now is to convert your WordPress template to a Movable Type style. Wailing and gnashing of teeth to ensue shortly.

If you have any problem converting your entries, feel free to leave me a comment. I cannot guarantee you that I will be able to help you, but I will do my reasonable best. As far as I can tell, I dotted every i and crossed every t when creating the export script. If it doesn't work, the most likely culprit would probably be some sort of character arrangement that screws it up. For some official documentation on the import/export format, check this out.

Related Entries:

18 Comments

Moving from WordPress to Movable Type part 2

Introduction of sorts Previously, I went over the process of converting your WordPress entries, comments and pings over to Movable Type. Now, here comes the real fun part. Rewriting your template! Yeah, you know you want dive right in there...

thanks. i have a loathing for WordPress that means i want to move something back to TypePad. this will come in handy ...

No problem. I tested that on my host without incident so you should be all set. The script is going straight into the public domain so you can modify it as you see fit.

Actually, i'm not having problems with compilation errors, its actually most likely my entries. What's happening is when I save it (in ANSI text with Unix file encoding), it will take the first entry's title and put it in with a random entry from the page. The PHP part works fine, I just can not seem to transfer the entries over. Any ideas why? -I also apologize if I at all offended you within my entry. Like I said before (and probably should have said in the entry), the export script is fine, its just doing funky things when I import it :)

No offense taken. I've had similar problems with encoding before. What I did last night with my fiance's blog was I ran the script, saved the output in Firefox to a text file, then just uploaded that text file as is.

I just checked the export file, and I think I realized where you may have gone wrong. The charset is UTF-8, not ASCII. You shouldn't need to do any conversions. Just try running the script again, then uploading it as is. If that doesn't work, all I can suggest is beating Movable Type with a big stick until it does what you want :)

I think I figured out my problem! When I ran the script, I would get errors like "wp_comments" does not exist. It's not until I read the actual errors that I figured out the problem. When the script took the comments, it tried to take them from a database table that did not exist as I had mine set to af_comments. So I went in and saw that where the comments were taken out, it simply said wp_comments and didn't have the $wpdb-> before the comments. Upon updating, I was successfully able to upload my entries. Thank you SO MUCH! Now on to part 2!

Hey, no problem. Glad someone else got some use out of it. Come to think of it, I probably should go back and update it because WordPress's WPDB class provides aliases to those tables, such as $wpdb->comments. Thanks for pointing that out.

Hi there,
Not to sound dumb, but how exactly does your script work? Where exactly on my server should I upload the script to? Thanks.

Ok, here's the deal. Copy that script to the same directory that wp-config.php is in, then run it. That will spit out a UTF8-encoded page of text that contains a standard Movable Type export format. You do not want to convert this to a different text encoding because that can complicate things.

I am in the process of making some aesthetic changes to the script. Right now it hard codes certain database table names in, and I am going to change that soon. As long as you are using the default installation options, though, it should work without a problem. I do not know how other blog suites will handle the output from that script, but Movable Type 3.3 has no problems with it from my experience using it on the blogs I manage.

If you are looking for an export script that translates themes, this won't work for you. Themes have to be rewritten to work with different blogging app suites. I had to take about 2 days of hard, painful work to switch that old theme (Connections) from WordPress to Movable Type by hand. Writing a script to automate that would be, shall we say, non-trivial.

Hi there,

first, thanks for the MT import script. I exported from WP 2.06 and imported to MT 3.34. I am sorry to tell you that it doesn´t work for me for 100% only the first half is ok. The import is the problem.

You may know that we in germany have that what you the english speaking folks name the umlauts (äöüß). The import breaks after the first umlaut in the title, stops importing and goes further with the entry and stops after the first umlaut in the entry etc. etc. . The result is a imported entry with maybe a single word in the title and 8 words in the entry.

I don´t know why, but i think you wrote a script for the english speaking community, yes, but from your post it should be UTF-8?

Best regards
Marcus

Uuuh, have annother problem: I changed all the umlauts to html code. Now the entries are more as complete. The last line is : ----- EXTENDED BODY:

Post No.3:

I got it. The problem was to copy and paste the output of the php script. I use Opera browser. In my case i now saved the script output as textfile and imported this textfile with Movable Type. Also the umlauts are correct. But it ( in my case ) does also import the last line of the entry: -----EXTENDED BODY. No idea why.

-Marcus

I just uploaded a few updates to the script that should address that problem. One puts in some manual newlines and the other adds the UTF-8 charset to the content-type header.

Moving from WordPress to Movable Type

I'm changing blogging platforms again. I'm now running the beta version of Movable Type 4. I found a lot of good documentation online for installing Movable Type on Dreamhost. In particular, I used: David Yin's Install MovableType 4 on Dreamhost...

Thanks for this import conversion script. It was just what I needed.

Hello,

Thanks for the kickass script. I noticed that if you don't use Wordpress' WYSIWYG editor the conversion doesn't work as smoothly since the formatting doesn't get carried over. Wordpress automatically adds a break for every new line. To "fix" this issue, I modified the script a bit.

I changed,
print "-----\n";
print "BODY:\n";
print $post[4]; //

to,

print "-----\n";
print "BODY:\n";
print str_replace("\n","",$post[4]); //

Hope it helps someone.

This also works for Squarespace.

We don't *officially* support a WordPress import yet, but I've personally referred people to these instructions to format their WordPress export in MT format (which can be imported into Squarespace.)

After you've exported in MT format, you'd just login to your Squarespace site and go to Data & Media > Data Backup & Restore > Journal Import to upload the file. The Squarespace system will import all of your entries, creating categories where necessary.

The only drawback is you cannot export/import images in your blog as easily. (This is the case with any Content Management System, unfortunately.)

Fix for WP 2.5

$categories = $wpdb->get_results("select $wpdb->terms.name from $wpdb->terms,$wpdb->posts where $wpdb->term
s.term_id = $wpdb->posts.post_category and $wpdb->posts.id = $post[0];", ARRAY_N);

Leave a comment

December 2008

Sun Mon Tue Wed Thu Fri Sat
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      
OpenID accepted here Learn more about OpenID

Creative Commons License
This blog is licensed under a Creative Commons License.
Powered by Movable Type 4.21-en
   

Site Credits

   
        Wordpress Themes by TemplateLite