After many years on the Textpattern blogging platform, I’ve migrated Place Name Here over to WordPress. Though it only took a day or two to migrate blog posts and comments dating back to 2004 and create a theme to match, it was a move that needed some massaging.
Why Change?
I had been contemplating the change for some time now. I’ve used both systems, as well as others like Movable Type, for personal and client projects and have a good feel for each system’s strengths. I was seeing that where WP was headed is more aligned with where I think I want to take this site. It isn’t that there was anything wrong with Textpattern—in fact in many ways I still prefer it’s simplicity, template system and other core features. But that project seemed to have plateaud and contributions, updates and roadmaps are sometimes unclear. WordPress has continued to move forward and make easier some of the features I’ve been wanting to add (pingbacks, gravatars, other blogging and infrastructure fluff). But since these weren’t pressing needs, I just kept bumping the move until recently when I had the time to look at it again.
Data Importer Hiccups & Changes
Having a relatively simple markup structure to begin with for the old site’s templates made the theme transition relatively easy. By creating a child theme of Twenty Ten and editing just 9 of the files (along with a bit of experience) got me to what you see now. Given this is only a migration of a 2+ year old markup and CSS that’s been tweaked a few times too many there is certainly cleanup that needs to be done when I get a chance, but a redesign is another challenge for another day.
What I did have to wrestle with was the data migration. The current Textpattern importer plugin seemed a bit out of date and for my needs it needed a bit of customization. The requirements I laid out for a successful migration from Textpattern 4.2.0 to WordPress 3.0.1:
- Post author needed to remain my user account in both systems.
- Old permalinks needed to work, so
/article/[ID]/[textstub]needed to be configured and IDs in the old system needed to be preserved. - Tags needed to be migrated from the old system to the new.
- Post Body and Excerpt HTML fields needed to be imported so I didn’t have to configure Textile parsing for all old articles.
Items 1 and 2 required a little massaging before import.
- Create the WordPress admin user with the same username as the author in Textpattern.
- Delete all test posts, comments and pages from the MySQL database to free up any IDs.
Customization of the textpattern-importer plugin was required to make the rest happen. It wasn’t really a heavy job, but three changes needed to be made.
Swap the use of the Body and Excerpt containing Textile code with the “compiled” Body_html and Excerpt_html fields.
// Get Posts
return $txpdb->get_results('SELECT
ID,
Posted,
AuthorID,
LastMod,
Title,
Body_html,
Excerpt_html,
Category1,
Category2,
Status,
Keywords,
url_title,
comments_count
FROM '.$prefix.'textpattern
', ARRAY_A);
Include the Keywords field (was this just overlooked? I don’t understand why it wasn’t there already). Also, insert the existing ID for each inserted post (as import_id).
$ret_id = wp_insert_post(array(
'import_id' => $OldID,
'post_date' => $Posted,
'post_date_gmt' => $post_date_gmt,
'post_author' => $authorid,
'post_modified' => $LastMod,
'post_modified_gmt' => $post_modified_gmt,
'post_title' => $Title,
'post_content' => $Body,
'post_excerpt' => $Excerpt,
'post_status' => $post_status,
'post_name' => $url_title,
'tags_input' => $Keywords,
'comment_count' => $comments_count)
);
What To Do With The Code Now?
I feel the need to share, but is it worth submitting back to the project?
I’ve uploaded both my customized importer plugin and a diff incase anyone else should want to attempt to use it. Please read my requirements above before you do, but it will probably be a smoother transition than the current plugin. I’d love to discuss contributing the changes back into the project with someone, but wouldn’t lobby for it without some discussion of which of my requirements are universal enough to make it (keywords, yes, HTML posts, dunno). Please use the comments section to let me know your thoughts on contributing this code back to WordPress—or report back if you’ve used the code.
Download pnh-textpattern-importer.zip which contains:
- textpattern-importer.php: (replace contents of
/wp-content/plugins/textpattern-importer/textpattern-importer.phpwith this file after installing existing plugin) - textpattern-importer.php.diff

Perfect! Just what I needed. How did you deal with file downloads and in-text images uploaded through the TP file uploader? Those do not seem to be ported. Images are ok to handle. I just copied all of them to the WP directory but downloads seem to be a bit more tricky.
Thank you for the updated import file and the comprehensive instructions!
Pingback: Textpattern Blog nach WordPress migrieren ยป open haus
Glad this was helpful Fabio. Unfortunately, I didn’t use the built in textpattern uploader so I didn’t look at that part of the importer or test it with my own content.
Taking a quick look at the importer I see it doesn’t move Images or Files from the database for any version of Textpattern, so this code would have to be written by someone. Maybe it has, so try some more targeted searches for just those pieces.
Thank you; your edits to the script worked perfectly for me.
Thank you, this was a life saver. You should flag this up on the WP codex which doesn’t haven’t any working solutions at the moment: http://codex.wordpress.org/Importing_Content#Textpattern
You are a lifesaver, champion of men, God! I have been stressing for weeks during the design process for a client. They had over 6,000 articles to move from Textpattern to WordPress. If you have a way for me (and others) to donate via PayPal I would love to donate. Send me a link on my website contact form so I can provide some gratitude!