-
Notifications
You must be signed in to change notification settings - Fork 4
Import WordPress XML into MODX
WARNING: This feature is not yet complete.
The goal is to import a WordPress XML file generated by the WordPress export tool.
WARNING: To fully emulate a WordPress site, your MODX site must install CraftsmanCoding's Taxonomies and Asset Manager Extras.
The process requires 2 steps: first a YML file is generated using the map:wpimport
command. This YML file defines how the MODX fields and Template Variables (TVs) will map to XLS columns. Once you have a valid mapping defined in a map file, you can reference the YML file in the export
command. Follow along for how to do this.
Log into your WordPress site and head to the Tools --> Export page and export your site's content (optionally, you can choose which content to export, e.g. filtered by category or post-type). The XML file that is generated will have a name like yoursite-plus-a-bunch-of-ridiculously-long-keyword-descriptions.wordpress.2015-04-14.xml
The next step requires an initial parsing of the WordPress XML file so we know what's in it. The map:importwp
command generates a map file (a YML file) which you will use to control how (or if) your WordPress content will be mapped to MODX fields:
php xls2modx map:wpimport /path/to/yoursite.wordpress.xml /path/to/importwp.yml
Specify where the yml file should be written. The contents have several sections, with comments:
WARNING! You must indent properly for your YML file for it to be properly parsed.
This is a complex task: your WordPress site has a lot of interrelated components and you need to ensure that you handle it appropriately.
WordPress tends to stash a lot of extraneous stuff in the database as "post-types", even when the content has nothing to do with posts. To skip a particular post-type, delete or comment-out the line from the "post_types" section of the YML file, e.g.
post_types:
# nav_menu_item: modDocument
page: modDocument
post: modDocument
# wpcf7_contact_form: modDocument
If desired, you can assign a MODX template id to each detected post-type -- this kicks in for content other than pages because by default only WordPress pages can specify a custom template.
default_templates:
page: 1
post: 2
custom: 3
There's no need to define template ids for post-types that you do not wish to import.
For your WordPress pages (or any custom post_type that may have a custom template assigned via a custom plugin), you can map specific WordPress templates to a specific MODX template.
templates:
some-page.php: 1
special-page.php: 2
WARNING: Back up your database before you import content!
php xls2modx import:wp /path/to/yoursite.wordpress.xml /path/to/importwp.yml