As this post is already fairly long in length, I did not go into every detail. Such as, I omit how to set your permalinks to match TypePad and how to make an MySQL query. I hope this post helps someone out there.
Although WordPress has a built-in import feature for TypePad/Movable Type, it does not import the slugs. (The slug is the post name formated for the URL for example a post titled “I Love Cheese” has a slug of “i-love-cheese” in WordPress.) The slugs are not export by TypePad nor import by WordPress. So WordPress creates new slugs for each post in the WordPress style. The three issues with this are:
- TypePad uses the underscore ”_” to separate words whereas WordPress uses the dash ”-”
- TypePad truncates the slug to 15 characters whereas WordPress does not
- TypePad will keep slugs that are not the same as the title
The first and second can be easily be fixed with a little bit of SQL on the database. But since the last one requires that you know explicitly the slug in TypePad, a modified import process needs to be done.
(These steps require that you do not have any post in your WordPress installation.)
The Modified Import Process
Exporting From TypePad
The first step is to get an export from TypePad with the slugs included. Adam Stiles has created a Movable Type template for this purpose . I did have to modify it to get all (actually about the last five years which all the post are within) the posts instead of the last 100.
Original:
<MTEntries lastn="100">
Modified:
<MTEntries days="1780">
Please note that this will only export posts which are published. Drafts will not be exported.
Save and publish the template as an Index Template. Then view the generate published file and save it to your computer.
Importing Into WordPress
The second step is to import the exported posts into WordPress. The default WordPress import will not import the slugs. In order to also bring in slugs, you will need to use Adam Stiles Movable Type importer.
- You must already have WordPress installed and configured.
- Upload the export posts file to your WordPress installation’s wp-admin directory.
- Download the MovableType importer and save as import-mt.php.
- Edit import-mt.php to include the name of the export file. For example if your export file was named export.txt, then modify the second line as such “
define('MTEXPORT', 'export.txt');”. - Upload import-mt.php to your WordPress installation’s wp-admin directory.
- Run, through your web browser, import-mt.php in your WordPress installation. (The first page that shows up is not an error, but just a message stating you must edited, which you have, “
define('MTEXPORT', '');” before moving to the next step.)
Trim Excess Off Slugs With SQL
(This part of the process assumes that no posts existed in your WordPress installation before you imported the TypePad post into WordPress. Although, I am sure you can still trim the desired posts with SQL code which targets the desired posts.)
The imported slugs are not the actually slugs; instead, they are the relative URL paths which happen to include the slugs. To get the proper slugs we will trim the excess. For this case, the format is ”/YYYY/MM/SLUG.html”. A simple MySQL query can trim this (I did this in phpMyAdmin):
UPDATE <WORDPRESS TABLE PREPEND>_posts SET post_name = INSERT( INSERT(post_name, LOCATE('.html', post_name), 5, ''), 1, 9, '' ) WHERE 1
The break down of the query
<WORDPRESS TABLE PREPEND>is the value you prefixed your database tables with during the configuration (the default is “wp”).- The query will update every record (every post). To target posts you will need, at the least, to modify
WHERE 1. post_nameis the post slug field.- INSERT
( str, pos, length, repstr)is a MySQL function we are using to “erase” part of the string we do not want. - LOCATE
('.html', post_name)returns the starting position of ”.html” is post_name. INSERT(post_name, LOCATE('.html', post_name)returns a string of ”/YYYY/MM/SLUG” which means we erased ”.html”.INSERT( INSERT(post_name, LOCATE('.html', post_name), 5, ''), 1, 9, '' )returns a string “SLUG” which means we erased ”/YYYY/MM/”.
Finally, the imported post have their respected original slugs. Which will make it far easier to mimic the URL structure of the TypePad individual archives with WordPress.
Hi! Why I can’t fill my info in profile? Can somebody help me?
My login is Kisakookoo!
This is my first post
just saying HI
very interesting, but I don’t agree with you
Idetrorce
[…] is an example from Mo Jebus: UPDATE _posts SET post_name = INSERT( INSERT(post_name, LOCATE(’.html’, post_name), 5, […]
Leave a Reply
All comments are moderated for approval after submission. Attention spammers do not waste your or my time by trying to comment.