DISQUS

Technosailor: Textpattern to WordPress Import Script

  • Pac · 3 years ago
    Hi,

    I am completely new to WP and just do not find where in admin panel is the "import" function....

    thanks
    Pascal
  • Aaron · 3 years ago
    What version of WordPress are you using?
  • Pac · 3 years ago
    1.5.2 the latest stable one...
  • Aaron · 3 years ago
    The importer works only with 2.0 which is forthcoming. It's in beta as we speak. "Use at your own risk":http://wordpress.org/download/nightly-builds/wordpress-2.0-beta-1.zip
  • Pac · 3 years ago
    Oh, ok... is it a version for previous release? does the one included in 1.5.2 works well?
  • Aaron · 3 years ago
    There is no version for previous release and I don't have any intention of releasing one. 1.5.x will soon not be the standard.
  • Pac · 3 years ago
    Ok I have installed the WP 2.0 RC1 and use the embedded script to import from Txp... I have the following error when I try to import posts :
    WordPress database error: [You have an error in your SQL syntax near '"INTERVAL 1 HOURS") AS post_date_gmt, ADDDATE(LastMod, "INTERVAL 1 HOU' at line 15]
    SELECT ID, Posted, AuthorID, LastMod, Title, Body, Excerpt, Category1, Category2, Status, Keywords, url_title, comments_count, ADDDATE(Posted, "INTERVAL 1 HOURS") AS post_date_gmt, ADDDATE(LastMod, "INTERVAL 1 HOURS") AS post_modified_gmt FROM txp_textpattern

    any idea?
  • Aaron · 3 years ago
    yeah, MySQL version difference. Delete those two ADDDATE lines at the end of that query.
  • Pac · 3 years ago
    mmm, now have this error again for posts import :
    "WordPress database error: [You have an error in your SQL syntax near 'FROM txp_textpattern ' at line 15]
    SELECT ID, Posted, AuthorID, LastMod, Title, Body, Excerpt, Category1, Category2, Status, Keywords, url_title, comments_count, FROM txp_textpattern"
  • Aaron · 3 years ago
    Can you post that line between code tags here so I can see whats up?
  • Pac · 3 years ago
    mmm, now have this error again for posts import :
    WordPress database error: [You have an error in your SQL syntax near 'FROM txp_textpattern ' at line 15]
    SELECT ID, Posted, AuthorID, LastMod, Title, Body, Excerpt, Category1, Category2, Status, Keywords, url_title, comments_count, FROM txp_textpattern"
  • Pac · 3 years ago
    [code]WordPress database error: [You have an error in your SQL syntax near 'FROM txp_textpattern ' at line 15]
    SELECT ID, Posted, AuthorID, LastMod, Title, Body, Excerpt, Category1, Category2, Status, Keywords, url_title, comments_count, FROM txp_textpattern[/code]
  • Pac · 3 years ago
    give-me your tags...
  • Aaron · 3 years ago
    standard HTML code tags, man. And I need the code, not the error.
  • Pac · 3 years ago
    ???? the code is just the one included in WP 2.0 RC1...supposed to be your code!?
  • Pac · 3 years ago
    Just to mention that I tried an import from Txp 4.0.1 ... if it helps...
  • Aaron · 3 years ago
    It is my code and I told you to remove the two ADDDATE lines from the code, then you reported you were still getting an error.

    So IF you followed my instructions and by doing so you still are getting an error, then I want to see the modified code.
  • Pac · 3 years ago
    Ok, now it is clear to me... Here is the code where I remove the 2 lines:
    return $txpdb->get_results('SELECT
    ID,
    Posted,
    AuthorID,
    LastMod,
    Title,
    Body,
    Excerpt,
    Category1,
    Category2,
    Status,
    Keywords,
    url_title,
    comments_count,
    FROM '.$prefix.'textpattern
    ', ARRAY_A);
  • Aaron · 3 years ago
    And that is still erroring?
  • Pac · 3 years ago
    yes! here it is :


    WordPress database error: [You have an error in your SQL syntax near 'FROM txp_textpattern ' at line 15]
    SELECT ID, Posted, AuthorID, LastMod, Title, Body, Excerpt, Category1, Category2, Status, Keywords, url_title, comments_count, FROM txp_textpattern

    Done! 0 posts imported.
  • Aaron · 3 years ago
    Why don't you grab the newly modified code from the "WordPress source":http://trac.wordpress.org/file/trunk/wp-admin/import/textpattern.php
  • Aaron · 3 years ago
    Just to let you know, I'll be making additional changes to the script tonight including the removal of ADDDATE functions. Download the newest cose above and remove those ADDDATE lines again. Make sure the last field before the WHERE has *no* comment next to it.
  • Pac · 3 years ago
    Though it was the same... will try it!
  • Aaron · 3 years ago
    No, it's constantly being modified because it is a _new_ script. ;)
  • Pac · 3 years ago
    What do you mean by "Make sure the last field before the WHERE has no comment next to it." ?
  • Aaron · 3 years ago
    I mean, make sure your SQL is correct.


    // Get Posts
    return $txpdb->get_results('SELECT
    ID,
    Posted,
    AuthorID,
    LastMod,
    Title,
    Body,
    Excerpt,
    Category1,
    Category2,
    Status,
    Keywords,
    url_title, comments_count FROM '.$prefix.'textpattern ', ARRAY_A);
  • Pac · 3 years ago
    In you last code, there is a comma after comments_count :

    comments_count,
    FROM '.$prefix.'textpattern
    ', ARRAY_A);
    where is the truth?
  • Pac · 3 years ago
    seems here comes the issue, will try without the comma
  • Pac · 3 years ago
    Yes no more the same error...will examine the result precisely!! happy to find a bug in your code ;-)
  • Aaron · 3 years ago
    at mysql.com, man. Commas separate fields. comment_counts is the last field you're selecting in the snippet I just gave you. In the old code, comma_count was followed by two more fields ran through the ADDDATE() function.
  • Pac · 3 years ago
    I presume it is normal to have lost all photos I had in my Txp post...
  • Aaron · 3 years ago
    No preservation of images was made. However, if you used Textile to render your images, download the Textile for WordPress plugin
  • Pac · 3 years ago
    Just to let you know, in order for you to improve the script if possible that the comments where all imported but without link to the post and the post itself the sql value "comment_count" was not updated too... done the trick through phpmyadmin but not so convenient if you import alot of comments
  • Aaron · 3 years ago
    Odd. Thanks for the note. I have reopened my bug report ticket and will work out the issue this evening. Thanks!!
  • Chris L · 3 years ago
    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...
  • Aaron · 3 years ago
    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 L · 3 years ago
    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!!
  • Aaron · 3 years ago
    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.
  • Aaron · 3 years ago
    And don't convert your Textile. Use the Textile for WP plugin.
    http://www.huddledmasses.org/2004/04/19/wordpre...
  • Chris L · 3 years ago
    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...
  • Aaron · 3 years ago
    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.
  • Chris L · 3 years ago
    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...
  • Aaron · 3 years ago
    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.
  • Aaron · 3 years ago
    You don't have to submit a bug report but if you do more eyes will be on the problem.
  • Brendan · 3 years ago
    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.
  • Aaron · 3 years ago
    No, but we can always do customization work for you if you need it.
  • Robert Ellis · 3 years ago
    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!
  • Aaron · 3 years ago
    What version of WP? What version of Textpattern?
  • Robert Ellis · 3 years ago
    I'm running Textpattern 4.0.3 and just installed WordPress 2.0.1.
  • Aaron · 3 years ago
    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.
  • Robert Ellis · 3 years ago
    I tried both importers, yours and the one that came with WordPress, and I get the same error messages with both. I don't think there were any changes to the database between 4.0.1 and 4.0.3.

    Am I supposed to import my Textpattern tables into the WP database before importing? Seems odd, but I thought I saw a comment regarding that above.
  • Aaron · 3 years ago
    It helps if they are in the same database, and it helps if they are on the same server, but no you don't have to import them. The importer does that for you.

    I am presuming you have actually installed WordPress succesfully before attempting to import?

    I also presume your WordPress table prefix is wp_?
  • Robert Ellis · 3 years ago
    Yes, WP was successfully installed and the table prefix is wp_. I moved the Textpattern tables into the WP database (they were in separate databases on the same server) and the import seems to be working now (I have a few hundred entries so it's taking a long time). Things seem to be okay so far. Thanks very much!
  • Aaron · 3 years ago
    Cool!

    The only thing I can think of is that the first page of the importer prompts you for your Textpattern database info and you might have thought it wanted your WP info.
  • Robert Ellis · 3 years ago
    Nope, I entered the info for the Textpattern database. It was only after moving the tables into the WP database and specifying the WP database that it worked. But I think I've got it now. Thanks again!
  • Andrei Maxim · 3 years ago
    Hi,

    It seems that there are some issues with UTF-8 characters, like ă, î, ş, ţ and â.

    What needs to be changed so I can see the proper characters instead of "?"?
  • Jack · 3 years ago
    For the record, I also had to add my existing textpattern tables into the target wordpress database before the import worked. Specifying a separate Textpattern database failed with the same error as above. (Textpattern 4.0.2 to WP 2.0.2)
  • brendon · 3 years ago
    I have another example of what Jack and Robert are reporting- my TXP install is 4.03, and I downloaded the newest Wordpress... I have the DB's on the same server, same install of mysql, but the import shows errors like this:

    WordPress database error: [Table 'textpattern.wp_bb_1_categories' doesn't exist]
    SELECT cat_ID FROM wp_bb_1_categories WHERE category_nicename = 'misc'

    WordPress database error: [Table 'textpattern.wp_bb_1_categories' doesn't exist]
    SELECT cat_ID FROM wp_bb_1_categories WHERE category_nicename = 'food-dining'

    Wherein "textpattern" IS the db name I entered on the previous page for my textpattern, and wp_bb_1 is the proper table prefix for this WP install.

    Does this mean the first step of your script is to create WP-style tables in my TXP db and map over the data, THEN export it to the WP database? Or is it somehow writing to the wrong one? Or do am I completely lost and should stop while I'm behind? :)

    ANyway- I'm going to try the "import tables into WP database" method for now and see how that works...

    Thanks...
  • brendon · 3 years ago
    ...Which is to say- after importing the tables into the WP db, and pointing the script to that, it worked like a charm.
  • a. · 3 years ago
    Hi! I'm hoping you can help me. I tried the import feature and get the following errors (among others...)

    When attempting to import textpattern posts to wordpress I get the following error:

    WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '/txp_category WHERE type = "article"' at line 5]
    SELECT id, name, title FROM /txp_category WHERE type = "article"
    No Categories to Import!

    Can you point me in the right direction to correct this? I don't know anything about importing tables,etc. Any help is appreciated. Thanks.
  • a. · 3 years ago
    I moved wordpress to the textpattern database and the import went smoothly. Thanks!
  • R Salama · 2 years ago
    Hello,

    I've done the import without any drama. And I've installed the textile for wordpress plugin, again without any drama.

    However, I use the following to produce a thumbnailed image that can be clicked to produce a full sized image in a new window:



    Now, this doesn't work after import, and it's a bit of showstopper. Any help?