I’ve migrated my blog to WordPress. This blog was running Textpattern originally. It’s now powered by WordPress with theme by Galindez. I like this theme. It’s plain black and white – the perfect palette to make people focus on contents.
Before I detail the update / migration process. I wanna say… Textpattern is a wonderful CMS. I used it for the past 5 years or so. It’s very flexible, stable, secure and fast. So, why switch? Well, it’s the theme. There’s not much good theme in Textpattern and I couldn’t afford to hire a designer to design one for me.
Now, back to the migration process…
There’s import script in wordpress. I was naive enough to think that I can import my textpattern database to wordpress seamlessly. The reality is not that smooth, actually. So, I wanna outline a process a bit. Hopefully, someone may find it userful!
Here’s what I need to preserve in the migration process:
- All my posts (for sure!)
- All comments
- The “section” of the posts
- Redirect links to post in the Textpattern blog to the new URLs in WordPress
Step 1 – Backup!
Backup your textpattern database. I use mysqldump command for this purpose.
Step 2 – Installing WordPress
Install WordPress in your. Then, remove the hello world in “Posts” section and the sample page in “Pages” section. Removing those system sample post and page is important cause I wanna preserve ID of blog post in Textpattern after migration.
Step 3 – Update Import script
This step many not be essential. But if you need to keep the ID of your blog posts consistent across the old and new site, you need to follow this step.
I am using WordPress 2.9.2. There’s a minor bug in the import script for Textpattern. Go to wp-admin/import/textpattern.php Line 337. Add “‘import_id’ => $ID,” to the array.

This allows WordPress to update the ID of the post using the ID in the Textpattern database.
Step 4- Image and file link
Textpattern stores the HTML version of your post in “Body_html” column. The “HTML” text there still contains some textpattern tag, namely, txp:image and txp:thumbnail. We need to change links to image from <txp:image /> tag to html <image /> tag.
I made a custom PHP script to perform this task. You can download here. The script is a controller sub-class that runs in CodeIgniter. You need to get a copy of it as well. You need basic knowledge to CodeIgniter to use the script. Look for line 12. You need to setup your a database connection in your own CodeIgniter instance.
Check line 36, 39, 56 and 59. This is where you specify the URL to the image. In my case, I created a “txp” folder in the server to store images from the previous system.
WordPress import script gets data from “Body” instead of “Body_html”. We should update the “Body” column with content of “Body_html” to avoid importing textile formatting to WordPress. In line 74, the update is purposely made to the “Body” column for this reason.
Step 5 – Running the import script
Go to WordPress admin panel. Click “Tools” > “Import” > Textpattern. Fill in the database connection information and run through the procedure.
Step 6 – Category mapping problem
Sections in Textpattern are imported as category in WordPress. But the script could not associate my posts with the correct category. I have to manually associate the post in WordPress to the correct category.
delete from wp_term_relationships where term_taxonomy_id = 1
create table id_map (post_id int, post_title varchar(255), term_id int)
insert into id_map SELECT wp.ID, wp.post_title, w.term_id FROM <txp db>.textpattern t INNER JOIN <wp db>.wp_terms w ON t.Section = w.slug INNER JOIN <wp db>.wp_posts wp ON wp.ID = t.ID
replace into wp_term_relationships select post_id, term_id, 0 from id_map
Redirect individual blog post link to the new WordPress blog
It’s just not a good user experience if links in my old blog all become dead links after migration. From SEO standpoint, I want the search engine to know that I have moved the links to a new one. There’s a plugin which allows you to set custom redirect rules in WordPress. Get it from here. It’s listed in WordPress Plugin page as well.
One minor issue though… I have over 500 posts. You won’t expect me manually entering the links. There’s a script doing that as well. Just look for the “url_generation” function in my previous script. Well, you may use a different URL convention in Textpattern than I do. I was using /section/$id/$title. The script only works if you use the same convention as well. Please also make sure you have set up the necessary database connection in line 79 and 80.
Done! Well, sort of…
You should be done with the import process. Well, you should be done with the technical process, at least. Now, it’s the tough time… adding new pages and writing up contents in those pages… I am still working on that