Wordpress offers a simple way to import content from many other blogging systems (details here) but what happens when your system isn’t listed there? Moving from one system to another isn’t necessarily a nightmare – especially if all your data is already in a database. I recently moved a lot of content over from a system called XOOPS to Wordpress. I had a hunt around to see if anyone else had done this and think I found a couple of perl scripts but they weren’t applicable to what I was wanting to do and I wanted to feel comfortable importing in the content.
The only thing I wanted to bring across from XOOPS were all the stories – these would be turned into Wordpress blog posts. It’s a very simple case because there is only one author, one category and no comments on the XOOPS content.
I had a look at how XOOPS was storing this content in the database using phpMyAdmin and compared this to how Wordpress stores its blog posts and matched up the XOOPS table fields with the Wordpress ones where possible.
| Xoops | Wordpress |
|---|---|
| title | post_title |
| storyid | ID |
| post_author = 1 | |
| post_category = 0 | |
| post_status = publish | |
| comment_status = open | |
| ping_status = open | |
| hometext | post_excerpt |
| bodytext | post_content |
| FROM_UNIXTIME(post_date) | post_date |
| FROM_UNIXTIME(published+43200) | post_date_gmt |
| FROM_UNIXTIME(post_date) | post_modified |
| FROM_UNIXTIME(published+43200) | post_modified_gmt |
| storyid | post_name |
Note:
- The content in this case was all written by one person so I didn’t need to worry about the author id but XOOPS stores this as uid. If there were a number of authors, the author data could be exported and imported into Wordpress too.
- The content wasn’t categorised (it’s organised by date only) so I didn’t need to worry about categories but this could be exported and imported too.
- XOOPS and Wordpress store their dates differently so I had to do a quick conversion between formats. The “+43200″ is the difference between New Zealand time and GMT.
Once this table matching had been done, this was converted into a MySQL statement:
SELECT storyid AS ID, 1 AS post_author, FROM_UNIXTIME( published ) AS post_date, FROM_UNIXTIME( published +43200 ) AS post_date_gmt, bodytext AS post_content, title AS post_title, 0 AS post_category, hometext AS post_excerpt, 'publish' AS post_status, 'closed' AS comment_status, 'closed' AS ping_status, '' AS post_password, storyid AS post_name, '' AS to_ping, '' AS pinged, FROM_UNIXTIME( published ) AS post_modified, FROM_UNIXTIME( published +43200 ) AS post_modified_gmt, '' AS post_content_filtered, "" AS post_parent, '' AS guid, '' AS menu_order, "" AS post_type, '' AS post_mime_type, 0 AS comment_count FROM `xoops_stories`
The resulting data was then imported into Wordpress.
Again, this was a nice and simple example because there were no comments on the entries so only one table was being exported from XOOPS. If you already have posts in Wordpress, you’ll need to be more careful about the IDs not conflicting with older entries as well. Since this was a new Wordpress install, I didn’t have this problem.
I also needed to update Wordpress’ post2cat by importing this data into it:
SELECT "" as rel_id, storyid AS post_id, 1 as category_id FROM `xoops_stories`
This matches up categories with the posts.
If you need to move from one system to another and there’s no automated convertor, it can often be quite simple to figure out what to do to convert.