I finally decided to go ahead with the conversion from Drupal to WordPress. I don’ thave anything against Drupal, it just didn’t work for me.
Luckily for me my site wasn’t that big so I could do things like categories, tags and slugs manually. All I wanted to copy across were the actual articles and the comments.
To convert the posts had to modify the script a bit because all my nodes in Drupal were of type story, not pages or posts, so I simply removed the where to clause.
# Use the Drupal database use andremiller_drupal; # Remove all current posts from WordPress TRUNCATE TABLE andremiller_wordpress.wp_posts; # Insert posts from Drupal into WordPress INSERT INTO andremiller_wordpress.wp_posts (id, post_date, post_content, post_title, post_excerpt, post_name, post_modified, post_type, `post_status`) SELECT DISTINCT n.nid `id`, FROM_UNIXTIME(n.created) `post_date`, r.body `post_content`, n.title `post_title`, r.teaser `post_excerpt`, IF(SUBSTR(a.dst, 11, 1) = '/', SUBSTR(a.dst, 12), a.dst) `post_name`, FROM_UNIXTIME(n.changed) `post_modified`, 'post' `post_type`, IF(n.status = 1, 'publish', 'private') `post_status` FROM node n INNER JOIN node_revisions r USING(vid) LEFT OUTER JOIN url_alias a ON a.src = CONCAT('node/', n.nid) ;
That takes care of the posts. Comments are next.
On my drupal site the email address was not compulsory, so some comments did not have this field filled in. I made a small change here to generate a fake email if none was provided by concatenating the name and hostname of the poster together.
The threading option also didn’t work for me, but wasn’t too important, so I just made that a ‘0’ to indicate no threading. In Drupal I was not using the approval feature, so the status of all my comments was set to ‘0’. In WordPress that meant they all came in as unapproved. I updated the SQL so all the comments would be imported as approved.
TRUNCATE TABLE andremiller_wordpress.wp_comments; INSERT INTO andremiller_wordpress.wp_comments (comment_post_ID, comment_date, comment_date_gmt, comment_content, comment_parent, comment_author, comment_author_email, comment_author_url, comment_author_ip, comment_approved) SELECT nid, FROM_UNIXTIME(timestamp), FROM_UNIXTIME(timestamp), comment, 0, name, IF(mail='', CONCAT(REPLACE(LOWER(name),' ', ''), '@', hostname, '.localhost'), mail), homepage, hostname, 1 FROM comments;
# update comments count on wp_posts table UPDATE andremiller_wordpress.wp_posts SET comment_count = (SELECT COUNT(comment_post_id) FROM andremiller_wordpress.wp_comments WHERE andremiller_wordpress.wp_posts.id = andremiller_wordpress.wp_comments.comment_post_id);
In Drupal my urls of the posts where /content/slug_name, and I wanted to keep those the same so any links from outside would stay the same.
To do this I updated the WordPress Permalink settings:
Custom Structure : /content/%postname%
And then made sure the slugname of each post matched the url alias of the article in Drupal.
However, this change made the tags and category urls end up to be /content/tag/<tagname> which I didn’t want. Changing them to the following fixed that up:
Category base: category
Tag base: tag
Now an article can be reached by /content/slug_name, and list of articles with a particle tag by /tag/tag_name.
So far, everything seems to be working just fine.