Was this article helpful?
Thanks for your feedback
In this section, we'll learn how to migrate content from WordPress to Contentstack.
To migrate content from WordPress to Contentstack, you will first need to export content from WordPress and then import the exported content to Contentstack.
There are two methods to export content from WordPress:
In this guide, we will go through each of these methods in detail.
Contentstack provides a tool that allows you to export content from WordPress using MySQL queries and makes it possible to import it into Contentstack. Using this project, you can easily export WordPress Users (authors), Categories, Media (assets), and Blog posts from WordPress and import them into Contentstack.
To do so, you need to perform the steps given below:
To install the node modules that are necessary for exporting the content into your file system, open a terminal, navigate to the root folder of the utility tool, and run the command given below:
bash npm install
"host":"<<mysql host>>", "user":"<<mysql username>>", "password":"<<mysql password>>", "database":"<<mysql database of wordpress>>"
In the above configuration details, you need to provide the MySQL host, username, and password, and also provide the name of the WordPress database content.
Note: When exporting content via MySQL, you can specify a user-defined prefix under the table_prefix parameter. By default, the value is set to wp_.
npm run export
This command will fetch data of authors, assets, categories, and posts from the downloaded XML file and convert them in JSON files that is supported in Contentstack. These files are stored in the path mentioned in the data key in the config/index.js file.
npm run export {module-name}
When exporting modules individually, make sure you follow the module sequence as given below:
This mans that, before exporting posts, you must have had exported assets, authors, and categories:
Now, to export the modules, you need to provide the absolute path of the file that stores the IDs, when running the following command in a terminal:
npm run export <<module name>> <<absolute_path_of_the_file>>
You can find the success and error logs of the export process under libs/utils/logs. The successfully run processes are recorded under success and the processes that have errors will be recorded under errors.
The logs for failed assets are recorded in failed.json and is stored under the master folder located where your exported data resides.
Note: This utility tool can be used to extract only the latest published version of an entry.
The latest published content will be exported in JSON format and stored at the location provided in the index.json configuration file from where you can later import the data into Contentstack.
There are certain limitations when exporting the content from WordPress. They are listed as follows:
The exported content is now ready to be imported into Contentstack. This content will be in JSON format and stored at the location provided in the index.json configuration file from where you can later import the data into Contentstack.
To import the content, check the Import Content into Contentstack section.
Contentstack tool allows you to export content from WordPress into an XML file and prepare it to be imported into Contentstack. Using this project, you can easily export WordPress Users (authors), Categories, Media (assets), and Blog posts from WordPress and convert them into a format suitable to be imported into Contentstack.
To do so, you need to perform the steps given below:
To install the node modules that are necessary for exporting the content into your file system, open a terminal, navigate to the root folder of the utility tool, and run the command given below:
bash npm install
Now, pass the absolute path of the exported file to the xml_filename key in the index.json file under the config folder of the exporter utility. This will enable the exporter utility to understand the location from where it has to pick up the XML file of the content.
Note: When exporting content via MySQL, you can specify a user-defined prefix under the table_prefix parameter. By default, the value is set to wp_.
npm run export
This command will extract data of authors, assets, categories, and posts from the downloaded XML file and convert them in JSON files that is supported in Contentstack. These files are stored in the path mentioned in the data key in the config/index.js file.
npm run export {module-name}
When exporting modules individually, make sure you follow the module sequence as given below, for example, before exporting entries, you must have had exported assets, environments, locales, and content types:
Now, to export the modules, you need to provide the absolute path of the file that stores the IDs, when running the following command in a terminal:
npm run export <<module name>> <<absolute_path_of_the_file>>
If you wish to export the categories module, you need to provide the absolute path of the file that stores the slugs of all the categories (the slugs are stored as comma-separated values in the file), when running the following command in a terminal:
npm run export <<module name>> <<absolute_path_of_the_file (slug for category)>>
You can find the success and error logs of the export process under libs/utils/logs. The successfully run processes are recorded under success and the processes that have errors will be recorded under errors.
The logs for failed assets are recorded in failed.json and is stored under the master folder located where your exported data resides.
Note: This utility tool can be used to extract only the latest published version of an entry.
The latest published content will be exported in JSON format and stored at the location provided in the index.json configuration file from where you can later import the data into Contentstack.
There are certain limitations when exporting the content from WordPress. They are listed as follows:
Now, refer the next section to learn how to import the exported content into Contentstack.
The exported content is now ready to be imported into Contentstack. This content will be in JSON format and stored at the location provided in the index.json configuration file from where you can later import the data into Contentstack.
To import the content, follow the steps mentioned in the Import Content into Contentstack document.
Was this article helpful?
Thanks for your feedback