Skip to content

Instantly share code, notes, and snippets.

@zachattack
Created February 14, 2019 19:52
Show Gist options
  • Save zachattack/c4f6093367b26bd3c21116488a7d640b to your computer and use it in GitHub Desktop.
Save zachattack/c4f6093367b26bd3c21116488a7d640b to your computer and use it in GitHub Desktop.

Export Migration and Mapping

If you have custom content types that you want to migrate from a Drupal 7 installation to a WordPress installation, you will need to have a few things in place to make it happen.

  1. Modify the default XML output templates to look and smell like a WordPress export.

  2. Mapping Categories If you have unique categories and you want them to match up with taxonomy that you have created on your new site, you will need intercept the categories that are presently applied and overwrite them.

  3. Create the needed Drupal views After installing the Views Data Export module, you need to navigate to your Views panel and create a view of the content in fields that you would like to export. From this view you create an Export View of that view. The export views don't have consistent editing abilities. So, in the pre-view (haha the jokes) experiement with the output to get the fields that you will need all organzed. Make sure you name your view and your data export views uniquely to make the commands easier to run and remember.

Eg. View name - Page Content Export page_content_export Posts Content Export post_content_export etc..

  1. Edit your view theme files The default XML template files can be found in the module contrib folder as you would expect in a Drupal project. Make some copies of the files and add them to your template so that your changes are unique to your theme. And because it is the right thing to do..

views-data-export-xml-body.tpl.php -- this is where you can write all your special wrapper outputs to reformat content, taxonomy terms, etc. The bulk of the unique changes will be handled in this file.

views-data-export-xml-footer.tpl.php -- closing wrapper of the output

views-data-export-xml-header.tpl.php -- add the unique wordpress header information that is required to be recognized a WXL style file.

Your Local Drupal install workflow

Drupal Module Needed

Views Data Export

Drush command to generate a file that you can import.

drush views-data-export [view-name] [display-id] [output-file.xml]

Example

drush views-data-export view_my_view_name data_export_all_items all_of_posts.xml

Backups and Import Commands

Importing a backup from Pantheon ala Drush

gunzip < yourdbname.sql.gz | drush sqlc

Your Local WordPress install workflow

Backups and Import Commands

Create a starting point backup that has your config and no posts in the DB.

wp db export

Then reset your DB so that you can test your progress

wp db reset

Import from the reset point that you created wp db import yourdbexportname.sql

Import posts using these plugins from WordPress

Auto Upload Images

WordPress Importer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment