Create a free account to get access to additional free training videos. Enjoy this free video from CraftQuest! Create a free account to get access to additional free training videos. Join the Community
Migrating a Website to Craft CMS
We learn how to get posts content out of WordPress using the WP JSON API and how we can extend the API to get the data we need in the format we need.
The WordPress JSON API is a powerful tool for exporting post content in JSON format, which can be used for migrating data to Craft CMS. Here are the key points to consider:
Limitations:
Accessing the API:
Importing to Craft using Feed Me:
Handling Categories:
Extending the WordPress JSON API:
add_action('rest_api_init', function() {
register_rest_field('post', 'category_data', array(
'get_callback' => function($post_arr) {
$post_obj = get_post($post_arr['id']);
return get_the_category($post_obj->post_category);
},
'schema' => array(
'description' => __( 'Category Data.'),
'type' => 'string'
),
));
f});
Importing Categories:
Remember, data manipulation during export is often necessary when migrating between CMSs. It’s best to prepare your data before importing it into Craft, allowing Feed Me to pull in data in the exact format you need.
For more information on modifying WordPress JSON API responses, refer to the WordPress REST API Handbook (developer.wordpress.org/rest-api/).
Migrating a Website to Craft CMS is made up of the following videos: