Import all your WordPress content, media, and users into Craft CMS with a single CLI command.
- WordPress Feature Support
- Requirements
- Setup
- Usage
- Supported Block Types
- Supported ACF Fields
- Extending
- Getting Help
| Feature | Supported |
|---|---|
| Posts | â |
| Pages | â |
| Media | â |
| Categories | â |
| Tags | â |
| Users | â |
| Comments | â (requires Verbb Comments) |
| Gutenberg | â (see Supported Block Types) |
| Custom post types | â |
| Custom taxonomies | â |
| ACF Fields | â (see Supported ACF Fields) |
Craft 5.5+ is required, as well as the CKEditor plugin. Verbb Comments is also required if you wish to import user comments.
The import makes use of WordPressâ REST API. The API has almost everything we need out of the box, except for a couple things. To fix that, youâll need to install a simple WordPress plugin that exposes some additional data to authenticated API requests.
To do that, save plugins/wp-import-helper.php to the wp-content/plugins/ folder within your WordPress site. Then log into your WP Admin Dashboard and navigate to Plugins. Press Activate for the âwp-import helperâ plugin.
Within your WP Admin Dashboard, navigate to Users and press Edit for an administratorâs user account. Scroll down to the âApplication Passwordsâ section, and type âCraft CMSâ into the âNew Application Password Nameâ input. Then press Add New Application Password.
Write down the username and generated application password somewhere safe. Youâll need it when running the import.
If you have any custom post types or taxonomies youâd like to be imported, youâll need to register them with the REST API, by setting 'show_in_rest' => true in the arguments passed to register_post_type()/register_taxonomy().
Tip
Post types and taxonomies created with Advanced Custom Fields are included in the REST API by default.
If youâre using Advanced Custom Fields, youâll need to opt into including your field groups in the REST API by enabling their âShow in REST APIâ setting.
Field groups registered via PHP can opt into being included in the REST API by passing 'show_in_rest' => true to acf_add_local_field_group().
Warning
If you have any Clone fields, edit their settings and ensure that Display is set to âGroupâ. Otherwise their values wonât get included in the REST API.
First ensure youâre running Craft CMS 5.5.0 or later.
Then run this CLI command:
> ddev composer require craftcms/wp-import --devNote
If you get the following prompt, make sure to answer y:
yiisoft/yii2-composer contains a Composer plugin which is currently not in your allow-plugins config. See https://getcomposer.org/allow-plugins
Do you trust "yiisoft/yii2-composer" to execute code and wish to enable it now? (writes "allow-plugins" to composer.json)Run this CLI command to initiate the import:
ddev craft wp-importYouâll be prompted for your WordPress site URL, as well as the username and application password you wrote down earlier.
Note
If your WordPress site is hosted locally with DDEV, youâll need to enable communication between the two projects. From your Craft project, create a .ddev/docker-compose.communicate.yaml file with the following contents:
services:
web:
external_links:
- "ddev-router:my-wordpress-project.ddev.site"(Replace my-wordpress-project with your actual WordPress project name.)
Then run ddev restart.
The command will then begin importing your content, creating content model components as needed, such as:
- A âPostsâ section for your posts.
- A âPagesâ section for your pages.
- An âUploadsâ filesystem and volume for your media.
- A âPost Contentâ CKEditor field with some nested entry types for storing non-HTML block data.
You can import any new content by running the command again later on. Or import just certain posts (etc.) using the --item-id option:
ddev craft wp-import --type=post --item-id=123,789By default, any content that was already imported will be skipped. You can instead force content to be re-imported by passing the --update option.
ddev craft wp-import --type=post --item-id=123 --updateTo see a full list of available options, run:
ddev craft wp-import --helpcore/audiocore/blockcore/buttoncore/buttonscore/codecore/columncore/columnscore/covercore/detailscore/embedcore/gallerycore/groupcore/headingcore/htmlcore/imagecore/list-itemcore/listcore/morecore/paragraphcore/preformattedcore/pullquotecore/quotecore/separatorcore/spacercore/tablecore/videocore-embed/twittercore-embed/vimeocore-embed/youtubecp/codepen-gutenberg-embed-blockdsb/details-summary-blockgenerateblocks/elementgenerateblocks/headlinegenerateblocks/imagegenerateblocks/mediagenerateblocks/textjetpack/slideshowjetpack/tiled-galleryvideopress/video
- Accordion
- Button Group
- Checkbox
- Clone
- Color Picker
- Date Picker
- Date Time Picker
- File
- Flexible Content
- Google Map (requires Google Maps or Maps)
- Group
- Icon Picker
- Image
- Link
- Message
- Number
- Page Link
- Post Object
- Radio Button
- Range
- Relationship
- Repeater
- Select
- Tab
- Taxonomy
- Text
- Text Area
- Time Picker
- True / False
- URL
- User
- WYSIWYG Editor
- oEmbed
There are three types of components that help with importing:
If your WordPress site contains unsupported content types, Gutenberg block types, or ACF field types, you can create your own importers, block transformers, or ACF adapters to fill the gaps.
Importers represent the high level types of data that will be imported (posts, pages, users, media, etc.). They identify where their data lives within the WordPress REST API, and populate new Craft elements with incoming data.
Custom importers can be placed within config/wp-import/importers/. They must extend craft\wpimport\BaseImporter. See src/importers/ for built-in examples.
Block transformers are responsible for converting Gutenberg block data into HTML or a nested entry for the âPost Contentâ CKEditor field.
Custom block transformers can be placed within config/wp-import/blocktransformers/. They must extend craft\wpimport\BaseBlockTransformer. See src/blocktransformers/ for built-in examples.
ACF adapters create custom fields that map to ACF fields, and convert incoming field values into a format that the Craft field can understand.
Custom ACF adapters can be placed within config/wp-import/acfadapters/. They must extend craft\wpimport\BaseAcfAdapter. See src/acfadapters/ for built-in examples.
If you have any questions or suggestions, you can reach us at support@craftcms.com or post a GitHub issue. Weâll do what we can to get you up and running with Craft!
