UPDATE: (Oct 23, 2010) Please read the comments below, especially the ones toward the end, for some relevant warnings about the latest versions of WordPress.
This week I spent several hours figuring out how to import all my entries from MoveableType to WordPress.
It turns out the task is non-trivial when you’re converting to WordPress 2.0 or higher (highly recommended) and you want to preserve the numeric permalinks of your posts.
If you want to keep your old permalinks alive for search engine purposes, and you’ve been using MT’s numeric filenames, then it’s crucial that you preserve the numbering assigned to your old entries.
If you conduct an ordinary import, however, any of the posts you had deleted in MT (e.g., test posts or any posts you decided to take down) will not get counted during WP’s import, causing the numeric IDs of your new posts to not match up with the old ones.
I was able to piece together a solution that worked, however. Below are my instructions.
1. Bone up on the general topic by reading WordPress’s own documentation on importing from MT to WordPress.
2. Edit MT’s export script to include post numbers. I don’t know the first thing about perl, but fortunately Dr. Bacchus provided some crucial guidance on this:
The module that handles MT exports is at lib/MT/App/CMS.pm. In sub export you’ll find a blob of text that starts with $tmpl->text(< <'TEXT'); and defines the template with which stuff will be exported. To that blob, add a new field:
Placement doesn’t matter. Save the file and upload it into your old MT installation.
3. Export your entries from MoveableType. Save the exported text file to your hard drive for later use. You might want to peek at the file in a text editor, to confirm that the headers for your posts include the numeric ID for that post.
4. Update WordPress’s script for importing entries. Find the file mt.php inside the folder /wp-admin/import, and rename the file to something like mtORIG.php (for backup purposes).
Then replace the file with this one. In the new version of this file, I’ve altered the function that updates the database, to include the post number when it does the update. (For esoteric reasons, this is not a trivial modification in WordPress v.2. They’re no longer using conventional SQL queries, for one thing.)
NOTE: I am not an experienced WordPress programmer, and I can’t make any guarantees about the fitness of my patch. If anyone with more experience sees problems with my script, please send them along and I’ll update my files accordingly. That said, the script worked like a charm for me — and for another person in the support forums who was having a similar problem.
5. Import your entries into WordPress. Once you’ve uploaded the revised import script into your WordPress installation, you should be able to import just like you normally would, inside the WordPress admin section: Click on the “Import” tab, choose “MoveableType,” and follow the instructions.
BONUS: There’s one other challenge when preserving your numeric permalinks, and that’s padding the zeroes in front of the post ID in the URL. Fortunately Kafkaesqui provides the solution: Edit the template-functions-links.php file (inside the /wp-includes folder). Look for the $rewritereplace array, and in it change:
That uses the WP function zeroise() to force the ID to 6 places by inserting zeros at left when it’s less than 6 digits.
Hope these instructions are helpful. I am available to answer questions on a limited basis. Please post your questions in the comments, below, so that others can benefit from the discussion.