I helped Katie setup her new blog this weekend and decided that [WordPress] offers much of what I want out of this blog for a lot less effort than drupal[1]. I decided it might be worth my time to now while this blog is in it's infancy to try converting from drupal to WordPress.
The way I start most of my projects is with a plan:
- Discovery: Find any articles about converting and get a gist of what to do.
- Implementation
- Create a temporary subdomain to install WordPress
- Install WordPress
- Copy all content
- Copy all static pages
- Configure URLs to match the existing site [2]
- adjust templates
- split entries correctly (i.e. change
<!--break-->to<!--more-->)
- Make the switch when I'm satisfied
I'm really confident that this will be easy. I don't even have to worry about comments or anything, since this blog is pretty new, but I can demonstrate how to take care of the.
Discovery
This post details a migration path from drupal to wordpress. Some considerations had to be made since I'm using [drupal] 4.7.
Implementation
Copy content
I followed most of the instructions, with some alterations from vrypan.net.
I installed [WordPress] and in mysql ran the following commands:
use wordpress;
delete from wp_categories;
delete from wp_posts;
delete from wp_post2cat;
delete from wp_comments
I run my [drupal] site in the same database server, so the data copying was a snap. If you aren't so fortunate, just copy the relevant drupal tables temporarily your wordpress database.
First we get the [drupal] categories into [WordPress]:
USE wordpress;
INSERT INTO
wp_categories (cat_ID, cat_name, category_nicename, category_description, category_parent)
SELECT term_data.tid, name, name, description, parent
FROM drupal.term_data, drupal.term_hierarchy
WHERE term_data.tid=term_hierarchy.tid;
Again with the posts:
INSERT INTO
wp_posts (id, post_date, post_content, post_title,
post_excerpt, post_name, post_modified)
SELECT DISTINCT
n.nid, FROM_UNIXTIME(created), body, n.title,
teaser,
REPLACE(REPLACE(REPLACE(REPLACE(LOWER(n.title),' ', '_'),'.', '_'),',', '_'),'+', '_'),
FROM_UNIXTIME(changed)
FROM drupal.node n, drupal.node_revisions r
WHERE n.vid = r.vid
AND type='story' OR type='page' ;
And the relation between posts and categories:
INSERT INTO wp_post2cat (post_id,category_id) SELECT nid,tid FROM drupal.term_node ;
And finally comments:
INSERT INTO
wp_comments
(comment_post_ID, comment_date, comment_content, comment_parent)
SELECT
nid, FROM_UNIXTIME(timestamp),
concat('',subject, '<br />', comment), thread
FROM drupal.comments ;
I ended up moving the one static page I had into [WordPress]'s "pages" section manually.
Since my pages are written in [Markdown], I enabled the Markdown for WordPress plugin.
URLs
Now for the real test. I needed to go through each page on my site and see if I could get to it using the same URLs. Since I had only 14 posts, I did this somewhat manually. I used [drupal]'s built in admin to do this from most popular to least popular. Most URLs worked fine. There were a small number that didn't for various reasons, I used custom mod_rewrite rules to handle them.
Adjusting Templates
My [drupal] template was fairly clean and simple. So I adjusted the CSS for the default theme in [WordPress] until I got what I liked. Very minimal changes had to be made to the actual "HTML."
Make the switch
Well, time to make the switch. In the WordPress administration, I just had to tell it that it's now going to be located at spindrop.us. Then I moved my [WordPress] installation to the [spindrop.us] web root. It was a snap. Let me know if you have any troubles.
- Taxonomy, legible URLs and trackback support all seemed quite difficult to master in Drupal. In Wordpress they appeared to be available standard or with a minor change in the administration panels. ↩
- This is a prime reason why URLs should be clean and make sense to the end user, not the programmer of the publishing software. ↩



When going with the posts (INSERT INTO wp_posts …) i receive this error:
please, anyone knows how to solve it?
zell:
Did you do this query exactly?
Note how I have
n.nidand not justnid? That should clear the ambiguation.Thanks,It works great!!
How do you migrate Drupal Users to Wordpress?
Michelle,
Unfortunately I don’t have an exact sql query, but try something like this:
I found it on another site. If this query doesn’t work, it should with minimal tweaking.
Excellent and easy to follow tutorial, but you forgot the Users and Groups. What is the sequel code to transfer those over?
Michelle, try the code I posted in the comments, it might need some tweaking so prepare to do some backups/rollbacks
Hello- I’m trying to use this script, and it doesn’t seem to work. When it says use “wordpress” and “drupal” in the script, am I supposed to replace those words with the actual name of the wordpress and drupal databases? I”m confused.
Thank you, Jeff
Jeff,
Yes, you need to use your actual database names.
I strongly urge you to fully understand these scripts before executing them. If that means learning some SQL syntax, it’ll be for the best.
Thank you, everything worked, except for the users. I wish there was a way to import those, but every other site that has drupal-to-wordpress directions also don’t work for me.
What version of Wordpress did you use when doing this? Thank you again, Dave.
At the insert posts option, I received this error “#1062 – Duplicate entry ‘3′ for key 1.” I used wordpress 2.01 because that was the version that was out when you made this post. I wonder what the error means?
Jeff,
I used the 2.x series. I suggest using the latest one even though you are right I prolly just used 2.01.
As for the duplicate error, it may be safe to ignore, it probably just means you have the same ID for a post. You can also clear out the destination table and try again.
any ideas about how to import from wordpress to publicsquare?
I got everything converted, but I’m having a devil of a time getting the Users over. When I use the script I get various error messages with the Unix Timestamp code (whether I leave it in or take it out) and if I use the code exactly as is, it won’t let me insert – here I’m assuming it’s because I’m already the default wordpress User at 1. Any suggestions? I’m on Drupal 5.1.
The topic is exactly what i want to do. however, first, i have my drupal site hosted with Godaddy. Godaddy provides phpMyAdmin 2.9.1.1 interface which allows my to backup or restore DB. Second, I have already backed up my ddrupal db. I have also installed Wordpress in a subdomain with a fresh new database.
Now…i am not sure what to do next. I know practically nothing about mysql. I logged into phpMyAdmin 2.9.1.1 but not sure what to enter and where (referring to your instruction above).
Could you help or give some pointers…please?
Thanks in advance.
-exo
exo,
I strongly recommend learning at least enough SQL and about PHPmyAdmin to be be confident, just so your not doing this blindly.
Everything mentioned here can be done using phpMyAdmin. What you’ll want to do is first backup your database.
You can then run these commands by clicking on an SQL tab once you’ve selected your database in phpMyAdmin. THe SQL tab will either give you a popup or a new page with a textarea that you can populate with one or more commands.
In your situation I recommend doing one command at a time, lest you run into errors.
Hope this helps you somewhat. Best,
-d
Hi, I visited your blog just now. Very nice. Thanks! Best Articles Site
Thank you very much. I went through hell with my phpMyAdmin and based on this post I made it!
I need to convert a Drupal theme (it is fairly basic, I created it with the Drupal Theme Generator) to a WordPress Theme, and I am having a very hard time figuring out how to do it. Can you help or point me in the right direction?
I dont think its too hard, you can take already converted themes and change them.