Textpattern to WordPress Import Script
I have not been posting much the past few days because I’ve been busy at work writing a detailed Textpattern importer for WordPress. This import script, should it be included in the core source code, will allow Textpattern bloggers to make the switch to WordPress.
We even have Textile, guys! Come on in, the water is nice!
But we don’t have to wait for the code to be dropped into the source. It is a part of the official WP 2 code now. Simply
# “Download textpattern.php”:http://trac.wordpress.org/file/trunk/wp-admin/import/textpattern.php
# Edit your Textpattern database details
# Rename textpattern.php
# Upload to wp-admin/import (replace existing)
# Login to wp-admin
# Click on Import > Textpattern
# Change Log
Some details provided during the import, but that you should also know before running.
h3. Users
You have already setup WordPress, but you also have users in Textpattern. We have taken care to import all of your users into our system. Unfortunately there is one downside. Because both WordPress and Textpattern uses a strong encryption hash with passwords, it is impossible to decrypt it and we are forced to assign temporary passwords to all your users. *Every _imported_ user has the same username, but their passwords are reset to password123*.
h3. Preserving Authors
Secondly, we have attempted to preserve post authors. If you are the only author or contributor to your blog, then you are safe. In most cases, we are successful in this preservation endeavor. However, if we cannot ascertain the name of the writer due to discrepancies between database tables, we assign it to you, the administrative user.
h3. Textile
Also, since you’re coming from Textpattern, you probably have been using Textile to format your comments and posts. If this is the case, we recommend downloading and installing “Textile for WordPress”:http://www.huddledmasses.org/2004/04/19/wordpress-plugin-textile-20/. Trust me… You’ll want it.
Enjoy.
v0.1 (Nov 23, 2005)
* Initial Release
v0.2 (Nov 25, 2005)
* Utilized WP API to insert links, cats, posts, comments and users
* Reinvented some WP API functions to assist in import
* Added link import
* Optimized code (Can anyone figure out how to make post/comment portion run in under 30 seconds”?)
* General aesthetic improvements
v0.3 (Nov 28, 2005)
* Moved $txpdb to after first step to prevent importer page from crashing for non-Textpattern importers
v0.4 (Nov 29, 2005)
* Gettext improvements
* Moved TXP Database Connection settings to user submitted form
* Stored TXP database connection settings in options table
* removed global txp database connection object and replaced with per function connections
* Removed ADDDATE() function from MySQL queries to prevent MySQL version < 4.1 issues
Pick up your copy of the WordPress Bible, a wildly popular resource for beginners and experts alike.
Popularity: 2% [?]



Odd. Thanks for the note. I have reopened my bug report ticket and will work out the issue this evening. Thanks!!
Odd. Thanks for the note. I have reopened my bug report ticket and will work out the issue this evening. Thanks!!
I just tried this script and it worked great… but I was wondering if it would be possible to have an option to maintain the same ID for posts?
My current URL scheme in textpattern is:
http://site/article/post-id/url-title
I can migrate to WP *and* maintain all the current links to my posts if I can keep the post-id the same during the transition…
I just tried this script and it worked great… but I was wondering if it would be possible to have an option to maintain the same ID for posts?
My current URL scheme in textpattern is:
http://site/article/post-id/url-title
I can migrate to WP *and* maintain all the current links to my posts if I can keep the post-id the same during the transition…
I just tried this script and it worked great… but I was wondering if it would be possible to have an option to maintain the same ID for posts?
My current URL scheme in textpattern is:
http://site/article/post-id/url-title
I can migrate to WP *and* maintain all the current links to my posts if I can keep the post-id the same during the transition…
Chris, I don’t think that will be possible. The reason is the WP API. When inserting posts, if you include an ID then WordPress assumes “edit” mode, not “insert” mode.
Chris, I don’t think that will be possible. The reason is the WP API. When inserting posts, if you include an ID then WordPress assumes “edit” mode, not “insert” mode.
Chris, I don’t think that will be possible. The reason is the WP API. When inserting posts, if you include an ID then WordPress assumes “edit” mode, not “insert” mode.
Too bad. Two other things:
1) when I Tried the script with my txp db being different from my wp db, it failed.
2) Is the post_name for the posts in the wpdb copied from the txp db (rather than re-created)? If so, I can probably write a script to update the new wp database with the proper post_id based on the post_name…
Then all I have to do is write a script to convert all the textile formatting in the wpdb and I think I’m done!
Thanks for your work on the import script!!
Too bad. Two other things:
1) when I Tried the script with my txp db being different from my wp db, it failed.
2) Is the post_name for the posts in the wpdb copied from the txp db (rather than re-created)? If so, I can probably write a script to update the new wp database with the proper post_id based on the post_name…
Then all I have to do is write a script to convert all the textile formatting in the wpdb and I think I’m done!
Thanks for your work on the import script!!
Too bad. Two other things:
1) when I Tried the script with my txp db being different from my wp db, it failed.
2) Is the post_name for the posts in the wpdb copied from the txp db (rather than re-created)? If so, I can probably write a script to update the new wp database with the proper post_id based on the post_name…
Then all I have to do is write a script to convert all the textile formatting in the wpdb and I think I’m done!
Thanks for your work on the import script!!
I tested it with my txp db being different…. In fact, that was how I developed it. However they do have to be on the same server unless the TXP db allows remote connections. Thats more a MySQL issue.
post_name is a direct copy of urltitle. I should have, in hindsight, ran TXP’s $Title through sanitize_title() but I did not. Theoretically they should be the same thing but I still prefer the safety of the WP API.
I tested it with my txp db being different…. In fact, that was how I developed it. However they do have to be on the same server unless the TXP db allows remote connections. Thats more a MySQL issue.
post_name is a direct copy of urltitle. I should have, in hindsight, ran TXP’s $Title through sanitize_title() but I did not. Theoretically they should be the same thing but I still prefer the safety of the WP API.
I tested it with my txp db being different…. In fact, that was how I developed it. However they do have to be on the same server unless the TXP db allows remote connections. Thats more a MySQL issue.
post_name is a direct copy of urltitle. I should have, in hindsight, ran TXP’s $Title through sanitize_title() but I did not. Theoretically they should be the same thing but I still prefer the safety of the WP API.
And don’t convert your Textile. Use the Textile for WP plugin.
http://www.huddledmasses.org/2004/04/19/wordpre...
And don’t convert your Textile. Use the Textile for WP plugin.
http://www.huddledmasses.org/2004/04/19/wordpress-plugin-textile-20/
And don’t convert your Textile. Use the Textile for WP plugin.
http://www.huddledmasses.org/2004/04/19/wordpre...
Well, the script wouldn’t work for me until I put them in the same db. It kept giving me errors because it was looking for my WP tables in the db I had specified for TXP– and it didn’t exist there. The fix was to move my WP tables to the same DB, then it worked fine. They are all on the same server.
As for Textile– thanks for the pointer. I am aware of the plugin, but I want to stop using it for various reasons, and if I turn it off in WP, then of course all my textile posts will look horrible. Ideally a plugin would let me select which formatting engine to use when (of course, ideally WP would store posts in both original and translated form as TXP does :), but since I haven’t found a good WP 2.0 solution for that…
Well, the script wouldn’t work for me until I put them in the same db. It kept giving me errors because it was looking for my WP tables in the db I had specified for TXP– and it didn’t exist there. The fix was to move my WP tables to the same DB, then it worked fine. They are all on the same server.
As for Textile– thanks for the pointer. I am aware of the plugin, but I want to stop using it for various reasons, and if I turn it off in WP, then of course all my textile posts will look horrible. Ideally a plugin would let me select which formatting engine to use when (of course, ideally WP would store posts in both original and translated form as TXP does :), but since I haven’t found a good WP 2.0 solution for that…
Well, the script wouldn’t work for me until I put them in the same db. It kept giving me errors because it was looking for my WP tables in the db I had specified for TXP– and it didn’t exist there. The fix was to move my WP tables to the same DB, then it worked fine. They are all on the same server.
As for Textile– thanks for the pointer. I am aware of the plugin, but I want to stop using it for various reasons, and if I turn it off in WP, then of course all my textile posts will look horrible. Ideally a plugin would let me select which formatting engine to use when (of course, ideally WP would store posts in both original and translated form as TXP does :), but since I haven’t found a good WP 2.0 solution for that…
Are you using the importer included with WP 2.0? The TXP database object is its own separate connection object with the variables passed in through a form on page 1 of the importer. It actually sounds like you might have an older version of the importer.
Are you using the importer included with WP 2.0? The TXP database object is its own separate connection object with the variables passed in through a form on page 1 of the importer. It actually sounds like you might have an older version of the importer.
Are you using the importer included with WP 2.0? The TXP database object is its own separate connection object with the variables passed in through a form on page 1 of the importer. It actually sounds like you might have an older version of the importer.
Yeah, it was in the WP I just downloaded today… if I have time I will try to replicate and be more specific. But I remember very clearly that on the very first section (categories) it was failing and the queries it was showing were being run against the wrong db…
Yeah, it was in the WP I just downloaded today… if I have time I will try to replicate and be more specific. But I remember very clearly that on the very first section (categories) it was failing and the queries it was showing were being run against the wrong db…
Yeah, it was in the WP I just downloaded today… if I have time I will try to replicate and be more specific. But I remember very clearly that on the very first section (categories) it was failing and the queries it was showing were being run against the wrong db…
Yeah if you can replicate that that’s great. Also submit a bug to WP since the importer is part of the official core now.
Yeah if you can replicate that that’s great. Also submit a bug to WP since the importer is part of the official core now.
Yeah if you can replicate that that’s great. Also submit a bug to WP since the importer is part of the official core now.
You don’t have to submit a bug report but if you do more eyes will be on the problem.
You don’t have to submit a bug report but if you do more eyes will be on the problem.
You don’t have to submit a bug report but if you do more eyes will be on the problem.
Will this also bring over custom Textpattern fields? My current Textpattern installation has several custom fields to hold post metadata; I guess I could fill them all in again in WP, but it’d be kind of a pain.
Will this also bring over custom Textpattern fields? My current Textpattern installation has several custom fields to hold post metadata; I guess I could fill them all in again in WP, but it’d be kind of a pain.
Will this also bring over custom Textpattern fields? My current Textpattern installation has several custom fields to hold post metadata; I guess I could fill them all in again in WP, but it’d be kind of a pain.
No, but we can always do customization work for you if you need it.
No, but we can always do customization work for you if you need it.
No, but we can always do customization work for you if you need it.
When I run the importer, I get these error messages:
WordPress database error: [Table 'future_futurosity.wp_options' doesn't exist]
SELECT option_value FROM wp_options WHERE option_name = ‘tpre’ LIMIT 1
Importing Categories…
WordPress database error: [Table 'future_futurosity.wp_categories' doesn't exist]
SELECT cat_ID FROM wp_categories WHERE category_nicename = ‘textpattern’
Etc. (it keeps going, and I get similar errors on every pageâ€â€users, posts, etc.).
Any help would be greatly appreciated!
When I run the importer, I get these error messages:
WordPress database error: [Table 'future_futurosity.wp_options' doesn't exist]
SELECT option_value FROM wp_options WHERE option_name = ‘tpre’ LIMIT 1
Importing Categories…
WordPress database error: [Table 'future_futurosity.wp_categories' doesn't exist]
SELECT cat_ID FROM wp_categories WHERE category_nicename = ‘textpattern’
Etc. (it keeps going, and I get similar errors on every pageâ€â€users, posts, etc.).
Any help would be greatly appreciated!
When I run the importer, I get these error messages:
WordPress database error: [Table 'future_futurosity.wp_options' doesn't exist]
SELECT option_value FROM wp_options WHERE option_name = ‘tpre’ LIMIT 1
Importing Categories…
WordPress database error: [Table 'future_futurosity.wp_categories' doesn't exist]
SELECT cat_ID FROM wp_categories WHERE category_nicename = ‘textpattern’
Etc. (it keeps going, and I get similar errors on every pageâ€â€users, posts, etc.).
Any help would be greatly appreciated!
What version of WP? What version of Textpattern?
What version of WP? What version of Textpattern?
What version of WP? What version of Textpattern?
I’m running Textpattern 4.0.3 and just installed WordPress 2.0.1.
I’m running Textpattern 4.0.3 and just installed WordPress 2.0.1.
I’m running Textpattern 4.0.3 and just installed WordPress 2.0.1.
And are you using the Textpattern importer that came with WordPress or did you download it from here?
I’m not aware of any database changes that came between TXP 4.01 (which is what I referenced when building the importer) and 4.03, but maybe you know of some as a TXP user.
And are you using the Textpattern importer that came with WordPress or did you download it from here?
I’m not aware of any database changes that came between TXP 4.01 (which is what I referenced when building the importer) and 4.03, but maybe you know of some as a TXP user.
And are you using the Textpattern importer that came with WordPress or did you download it from here?
I’m not aware of any database changes that came between TXP 4.01 (which is what I referenced when building the importer) and 4.03, but maybe you know of some as a TXP user.