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]
Tags: cms, hack, import, Just blogging, php, script, Textpattern, Wordpress
I’m also using WP since ‘04, but I’m always learning something new.
-Mark
Thanks for these instructions.
The textpattern.php was driving me nuts.
Thanks for this, as you say the standard textpattern.php doesn’t work. Thanks again.
thanks
It’s not working for me. =( I’m trying to do it, but I get this error:
Fatal error: Call to undefined function: register_importer() in /home/****/public_html/textpattern/wordpress/wp-admin/import/textpattern.php on line 917
I get the same error as Maria above.
Could be something changed in the newest versions of Wordpress. I’ll take a look at it someday, but till then you’re on your own, sorry….
New problem now:
I’ve gone through the “import” from the admin interface and right after I click “import posts” WP logs me out and resets my password.
(followed all steps above, including replacing the textpattern.php and making sure they’re in the same database)
[...] Die alten URLs sollte funktionieren, dank dieses Migationsskripts [...]
My script just wont select my database…what am I doing wrong here? I moved tables from the old TP DB to my new Wordpress DB, and gave it the same info, and the script just cannot find the DB.
@ Maria (Comment No 8): Actually, the new import script from 2.2 works. However, if you – before importing TXP-articles – have already changed the username into the same username used in the TXP-database, its password is reset to password123. Either you log in with the new password or you just import everything and afterwards deal with usernames, etc…
Thanks for this! I was having fits with the import in 2.2.2, your version did the trick.
[...] Subscribe August 14th, 2007 » How to import Textpattern into WordPress. For some reason the textpattern.php import script that ships with WordPress is buggy. This guy [...]
Hi.Thanks for your post .Your article make great idea to me.Thanks.
Simply great plugin for WP masters..
Thank you for this – after drawing a deep breath I finally made the move to WP – and it’s saved a lot of work.
I’m using the permalink structure /%category%/%postname% which worked a treat, just have to re-assign the Categories as they have all come in to the default one – but that was probably my fault somewhere.
Cheers.
is there a way to do it without having the username or password for the old database
mk – the username and passwd for the old db are stored in a config file in the textpattern/wordpress directory. Take a look in there and you’ll find them eventually
[...] out with an older version of Word Press because the default importer is rather borked. So, I found a blog post detailing how to correctly import the old DB. The reason that I had to have an old version (2.1, to [...]
[...] anyone wants to know hoe to do this, see Alex Brie’s great article. You don’t have to use the transfer your information to another database bit [...]
Thanks for this
[...] the method explained by Alex Brie I got WP up and running pretty quickly, only complicating matters myself by writing my own theme to [...]
[...] I found out that a few people have had issues with this script. A couple of other people (such as Alex Brie) have written their own instructions and even scripts (or at least modified the one that comes with [...]
[...] opportunity for sanity checking. No warranties express or implied yadda yadda. Thanks to Alex Brie’s script for [...]
Nice! Is it work at WP 2.5?
Yes, I think it’s work!
@Upoznati nekog: Yes, it works with 2.5
[...] from Textpattern. Obviously, I did a Google search: “textpattern to wordpress” and the top result did the job very well! As you can see below the old posts are there [...]
[...] my data from Textpattern. Obviously, I did a Google search: “textpattern to wordpress” and the top result did the job very well! As you can see below the old posts are there [...]
thanks!
It didn’t import everything (I had a bunch of plugins) but it imported what I needed!
Thanks for the script, this let me finally port my girlfriend’s blog from textpattern to something sane.
[...] Alex Brie:s steg-för-steg-guide för att migrera från Textpattern till Wordpress [...]
thanks for the script, it worked really nice. I’m not sure if I did something wrong – the original categories have been imported alright but the posts have been assigned to ‘uncategorised’ – any idea why?
I can’t seem to get the script to see my data. I copied everything over I have tried the Textpattern info and the WP DB info and it just comes back and says there is nothing to import. Any Ideas?
[...] al tuturor articolelor dintr-o categorie, intr-una noua? Daca nu, asta e, va trebui sa imi bag iarasi coada direct in [...]
Thank you so much for sharing your steps with us!
[...] Alex Brie:s guide [...]
Great piece of code!
I’ve adjusted it to work with siteframe on my website http://www.e-lyricz.com (1200 users 14000 posts)
I am trying to import the 1200 authors. Is there a way that I can force to insert their ID like with the posts? (function wp_insert_post_force_id).
So something like a ‘wp_insert_user_force_id’ function?
Is that hard to write?
I am not having much luck with that yet.
[...] Installing WordPress was a breeze. The five-minute install worked perfectly. Of course, I first installed it on my local environment to start developing a new design and template, and to test importing content from TextPattern, the CMS that I’ve used routinely over the last two years. As it turns out, moving my existing content from TextPattern to Wordpress had it’s snags, but I found some great advice, along with a better TextPattern to WordPress import script from Alex Brie. [...]
thank you very much Alex!
Hello!
Very Interesting post! Thank you for such interesting resource!
PS: Sorry for my bad english, I’v just started to learn this language
See you!
Your, Raiul Baztepo
Thank you so much for the revised script. Ihave some tidying up to do on categories, but otherwise your script has made installation of WP painless and I know get to catch up with the latest developments. I liked the principles behind textpattern, but it is hard to see how it can gain any fresh momentum.
Why is your script not included in the standard package I ask myself given that, as predicted, the one included does nothing.
[...] well. Fortunately, Alexandru Brie, a Romanian programmer and IT consultant, came to the rescue with revised guidance and an updated script. Share and [...]
Fixing the comment links
Subsequent to my last comment, I discovered that whilst all of the posts and comments seemed to have been imported from Textpattern to Wordpress successfully, I discovered that the comments had not been linked in correctly.
I had a friend knock up a script to resolve the problem and relink the comments to the correct posts just by matching text on the corresponding systems. Not sure why the original scrip had problems on my system and no doubt this can be fixed. In the meantime, I have pasted a copy of the script in one of the comments on my blog.
See http://kyber.co.uk/blog/textpattern-to-wordpress/
A couple questions after running an import on a site:
It looks like post category conversions (lines around 590) are using assignment instead of comparisons. That is:
if($cat1 = get_catbynicename($Category1)) { $cats[1] = $cat1; }
instead of
if($cat1 == get_catbynicename($Category1)) { $cats[1] = $cat1; }
More importantly, $Category1 doesn’t seem to be assigned a value anywhere
Finally, HTML entities in posts, such as nice quotes (ex: ’) get lost somewhere in the conversion.
Hi! Two questions:
1 – I’m thinking about migrating to WP from Txp. I have Textpattern 4.0.6 currently and would be converting to WordPress 2.7.1. Will the above instructions work for this particular combination?
2 – Are you glad you converted!? I’m doing so in order to help a community (http://sfcomplex.org/) use it, including building plugins. Txp has been fine for me, but I’m a pretty light user.
— Owen
[sorry for the repeat, the earlier attempt failed. Not sure why]
Hi! I converted my TxP to WP today following the instructions here. Here are some notes:
1 – To install my TxP tables into the WP DB, I used the mysql command line tools. This included:
- Dump the TxP DB:
mysqldump –opt -u NAME -pPW TXPDB > txpdb.sql
- Import into WPDB:
mysql -u NAME -pPW WPDB wptxpdb.sql
- Deleted all the TxP tables from the WPDB. Then saved again:
mysqldump –opt -u NAME -pPW WPDB > wpdb.sql
- Sizes were interesting. Note the WPDB was much smaller:
7.6M Aug 2 19:48 txpdb.sql
459K Aug 2 20:45 wpdb.sql
8.0M Aug 2 20:28 wptxpdb.sql
Why? The Log table in TxP was huge.
4 – Several future tweaks lie ahead:
- Fix categories. Fix/adapt to static pages which I used in TxP too.
- Move away from image handling used by TxP which uses an images directory with odd substructure and names like 1.png etc. Go to a more human style of an image directory with real names. Do the same in WP unless there is an apparent reason not to.
- Lots of reformatting and figuring out the CSS/Theme approach.
- Lose Textile. As much as I love it, I want to stick with basics: very simple HTML with CSS/Themes doing the heavy lifting. The WP editor is fine.
5 – TxP vs WP
- Win-Win .. both are great. Different styles of communities, different approaches to admin panel. TxP way nicer in some ways, WP in others.
- I plan to stay more flexible so that I can move away from either WP & TxP toward other new engines. In particular, I’m fascinated with SSJS (Server Side Java Script). So I really want a good export/import strategy.
- Cloud: I’m using cloud computing (Amazon, Aptana, Google App Engine, …) so I’m hoping some of these adapt nicely to WP or the SSJS strategy.
6 – A GREAT BIG HUG for this very helpful conversion blog entry. You’ve made lots of folks very, very happy. God bless you.
[One more try. This should go between the 1 & 4 paragraphs above. Sorry!!]
Then ran the new txp import script, natch
2 – Looked at the results. Some problems:
- Categories were imported, but the posts were still Uncategorized
- Some formatting problems. Probably easily fixed.
- Because I too wanted the same post ID, I had to delete the About Page post, and I’m a bit concerned that may cause future problems.
3 – Saved WP DBs in case I decide to once again start over:
- Saved WPDB with all TxP tables:
mysqldump –opt -u NAME -pPW WPDB > wptxpdb.sql
- Deleted all the TxP tables from the WPDB. Then saved again:
mysqldump –opt -u NAME -pPW WPDB > wpdb.sql
- Sizes were interesting. Note the WPDB was much smaller:
7.6M Aug 2 19:48 txpdb.sql
459K Aug 2 20:45 wpdb.sql
8.0M Aug 2 20:28 wptxpdb.sql
Why? The Log table in TxP was huge.
backspaces: sorry I can’t be of much help, I have written this article more than 2 years ago and it’s highly probable wordpress had some major changes since then. If my script didn’t work, you could still try to use WP’s included import from textpattern mechanism , in case it got updated as well.