30 Mar, 2007
How to import Textpattern into Wordpress
Posted by: Alex In: Textpattern| Tutorials| Wordpress
IMPORTANT ANNOUNCEMENT: This article was published more than 2 (TWO) years ago. It has helped, apparently, quite a lot of people migrate to Wordpress. However, there are high chances it has become highly outdated or even harmful. Before trying the steps and script I described here, you should try to use the migration script included in Wordpress. Chances are it got updated in the last 2 years and is now better than this (old) script.
I’ve talked a bit about this before : in my years of blogging I switched from a Blogspot account to Livejournal and finally, in 2004, to a self-hosted stand-alone blog. The main criteria for my CMS-blogging engine back then was simple: does it have RSS? can I have several Sections; is it nice-looking? Textpattern had it all at the time and I went for it. But, after a while, Wordpress 1.5 came along and I started getting angry that it had all this power: plugins, community, easy-to-hack framework.
Bottom line, I’ve been dreaming for 2 years already to migrate my Textpattern blog into a Wordpress one, one that I could easily hack, extend and theme. Finally, the day before yesterday (March 31 2007) I pulled myself together and started doing it.
Have you ever wanted this? If so, then tough luck: the instructions over here suck; so does the info from this wp thread.
So, without much ado, here are my instructions on migrating Textpattern 4.0.4 to Wordpress 2.1:
Requests:
- I wanted to keep the permalinks working – they were of the form http://alexbrie.net/myblog/blog/397/fornetti/ – my blog was located at http://alexbrie.net/myblog/, I had two main sections (4 in total, but only 2 had important articles) Words and Blog. So the texpattern permalink was like: domain_name/blog_directory/section_name/post_id/post_title.
- Also, I wanted the address http://alexbrie.net/myblog/ to remain valid and point to a Wordpress section with my previously imported posts.
- Third: in the myblog directory I also had the folders files and images that I wanted to keep – or else, my previous posts that contained images would have gone bad…
In order for the Wordpress permalinks to remain the same, first of all, the article-section associations would have to get imported, and the article ids should remain the same.
1. The first step was to save a dump of my Textpattern database: from my Dreamhost account I went to the phpMyAdmin page where I selected export database (as gzipped); remember to chack the Save DATA options as well.
2. On my home computer I had a working phpMyAdmin install, and a Wordpress 2.1 install; you can probably skip this step if you don’t want to test things locally at first; in the end, after the import process, I exported this local Wordpress database into a gzipped file which I reimported from within Dreamhost – this is the easiest way of copying a database from your computer to the Dreamhost one…
3. Now: if you are to try the Wordpress2.1 textpattern import script(found at wp-admin/import/textpattern.php), you’d be disappointed really fast: the script doesn’t work, it spits out plenty of errors and doesn’t get anything done. Textpattern.php script has a bug and wants (despite what it says in the beginning) the textpattern tables to be in THE SAME database as the wordpress ones. I did this part by hand: phpMyAdmin, go to the textpattern database, select the first table, go to options, select “move to database”, chose the wordpress database. Repeat and rinse for about 15 times (the number of textpattern tables); you don’t really need to do this for all the tables, but I did it for safety.
4. Rerunning the wordpress textpattern import script goes ok this time: articles are imported, so are users, categories, comments, etc. Still:
- the sections are not imported
- the articles ids are changed – we wanted them to stay the same, remember?
- the articles are imported in Textile formatting – this is the default markup language used by Textpattern; Wordpress, instead, uses HTML by default. Which makes all your imported articles look messy, without any formatting, without links and images.
4. So after quite a bit of hacking I put together a modified version of the textpattern.php import script: it imports the Textpattern Sections as Wordpress Categories and keeps the article ids the same; also, instead of importing the Body and the Excerpt for the articles(which by default are Textile), imports their HTML versions – thus making the article look nice.
Before I can use it, though, I’d have to clean up the Wordpress database – since I already imported stuff that I don’t like: from phpMyAdmin, in the wp database, select all the tables EXCEPT the users tables and the options table and “Empty” them.
Download: textpattern.txt script – rename it to textpattern.php, replace the existing wp-admin/import/textpattern.php (make sure to make a backup first) and rerun the process.
For me, it worked like a charm!
Are we done yet? Not quite:
5.I went to my Wordpress Admin interface and started tweaking the categories: since I managed to import my Blog and Words sections as categories, I edited all the remaining ones and specified those two as the parents (well you can only pick one parent, but you’ll manage); I also created a “root” category called “myblog” and specified it as the parent for Blog and Words. Now, my Wordpress categories hierarchy is a tree with the root “myblog”, it’s children “Blog” and “Words” and the rest of the children(leaves) being the remaining categories.
6. From the Permalink section in the Options tab from Wordpress, I chose /%category%/%post_id%/%postname%/ as the permalink structure. This matches, more or less, the initial domain_name/blog_directory/section_name/post_id/post_title aka http://alexbrie.net/myblog/blog/397/fornetti/ format.
Are these instructions enough for you? I hope so. If not, please drop me a comment. I don’t promise I can help you, but we can see…
[tags]Textpattern, Wordpress, import, script, php, hack, blog, cms[/tags]