Technosailor.com Readers! Donate today to assist the VIDA/COADHA Haiti Medical Response in their efforts.

22 November 2005 186 Comments

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% [?]

186 Responses to “Textpattern to WordPress Import Script”

  1. Aaron 30 November 2005 at 8:49 am #

    Odd. Thanks for the note. I have reopened my bug report ticket and will work out the issue this evening. Thanks!!

  2. Aaron 30 November 2005 at 7:49 am #

    Odd. Thanks for the note. I have reopened my bug report ticket and will work out the issue this evening. Thanks!!

  3. Chris L 8 January 2006 at 12:16 am #

    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…

  4. Chris L 8 January 2006 at 12:16 am #

    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…

  5. Chris L 8 January 2006 at 12:16 am #

    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…

  6. Aaron 8 January 2006 at 12:32 am #

    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.

  7. Aaron 8 January 2006 at 12:32 am #

    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.

  8. Aaron 8 January 2006 at 12:32 am #

    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.

  9. Chris L 8 January 2006 at 12:57 am #

    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!!

  10. Chris L 8 January 2006 at 12:57 am #

    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!!

  11. Chris L 8 January 2006 at 12:57 am #

    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!!

  12. Aaron 8 January 2006 at 1:20 am #

    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.

  13. Aaron 8 January 2006 at 1:20 am #

    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.

  14. Aaron 8 January 2006 at 1:20 am #

    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.

  15. Aaron 8 January 2006 at 1:22 am #

    And don’t convert your Textile. Use the Textile for WP plugin.
    http://www.huddledmasses.org/2004/04/19/wordpre...

  16. Aaron 8 January 2006 at 1:22 am #

    And don’t convert your Textile. Use the Textile for WP plugin.
    http://www.huddledmasses.org/2004/04/19/wordpress-plugin-textile-20/

  17. Aaron 8 January 2006 at 1:22 am #

    And don’t convert your Textile. Use the Textile for WP plugin.
    http://www.huddledmasses.org/2004/04/19/wordpre...

  18. Chris L 8 January 2006 at 1:31 am #

    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…

  19. Chris L 8 January 2006 at 1:31 am #

    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…

  20. Chris L 8 January 2006 at 1:31 am #

    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…

  21. Aaron 8 January 2006 at 1:32 am #

    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.

  22. Aaron 8 January 2006 at 1:32 am #

    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.

  23. Aaron 8 January 2006 at 1:32 am #

    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.

  24. Chris L 8 January 2006 at 1:45 am #

    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…

  25. Chris L 8 January 2006 at 1:45 am #

    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…

  26. Chris L 8 January 2006 at 1:45 am #

    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…

  27. Aaron 8 January 2006 at 1:47 am #

    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.

  28. Aaron 8 January 2006 at 1:47 am #

    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.

  29. Aaron 8 January 2006 at 1:47 am #

    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.

  30. Aaron 8 January 2006 at 1:48 am #

    You don’t have to submit a bug report but if you do more eyes will be on the problem.

  31. Aaron 8 January 2006 at 1:48 am #

    You don’t have to submit a bug report but if you do more eyes will be on the problem.

  32. Aaron 8 January 2006 at 1:48 am #

    You don’t have to submit a bug report but if you do more eyes will be on the problem.

  33. Brendan 20 January 2006 at 2:43 am #

    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.

  34. Brendan 20 January 2006 at 2:43 am #

    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.

  35. Brendan 20 January 2006 at 2:43 am #

    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.

  36. Aaron 20 January 2006 at 7:43 am #

    No, but we can always do customization work for you if you need it.

  37. Aaron 20 January 2006 at 7:43 am #

    No, but we can always do customization work for you if you need it.

  38. Aaron 20 January 2006 at 7:43 am #

    No, but we can always do customization work for you if you need it.

  39. Robert Ellis 11 February 2006 at 12:14 pm #

    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!

  40. Robert Ellis 11 February 2006 at 12:14 pm #

    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!

  41. Robert Ellis 11 February 2006 at 12:14 pm #

    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!

  42. Aaron 11 February 2006 at 12:16 pm #

    What version of WP? What version of Textpattern?

  43. Aaron 11 February 2006 at 12:16 pm #

    What version of WP? What version of Textpattern?

  44. Aaron 11 February 2006 at 12:16 pm #

    What version of WP? What version of Textpattern?

  45. Robert Ellis 11 February 2006 at 12:31 pm #

    I’m running Textpattern 4.0.3 and just installed WordPress 2.0.1.

  46. Robert Ellis 11 February 2006 at 12:31 pm #

    I’m running Textpattern 4.0.3 and just installed WordPress 2.0.1.

  47. Robert Ellis 11 February 2006 at 12:31 pm #

    I’m running Textpattern 4.0.3 and just installed WordPress 2.0.1.

  48. Aaron 11 February 2006 at 12:37 pm #

    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.

  49. Aaron 11 February 2006 at 12:37 pm #

    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.

  50. Aaron 11 February 2006 at 12:37 pm #

    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.