Migration Tips and Tricks - mergeweb/docs GitHub Wiki
This wiki page is designated to resolve some headaches in the migration process
- Install WP Export PRO plugin on source website.
- Create export file and download bundle
- Install WP Import PRO onto local environment and import posts. Posts must have title, content, author, date, and all images.
- Download Convert to Blocks plugin.
- Go to plugin settings and verify only posts will be converted to blocks.
- Connect to local env server via SSH (open shell in Local)
- Run
wp convert-to-blocks start --post-type=postand follow instructions to convert all posts to blocks. - Once this script is complete, create new WP script (either in functions.php temporarily or in a custom wp-scripts plugin). This wp script will be named "wp mass-wrap":
// wp-cli command to wrap all posts in columns
if (defined('WP_CLI') && WP_CLI) {
WP_CLI::add_command('mass-wrap', function () {
$args = [
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => -1,
'fields' => 'ids',
];
$posts = get_posts($args);
foreach ($posts as $post_id) {
$post = get_post($post_id);
$content = $post->post_content;
if (strpos($content, 'wp-block-columns') !== false) {
continue;
}
$wrapped_content = <<<HTML
<!-- wp:columns -->
<div class="wp-block-columns"><!-- wp:column -->
<div class="wp-block-column">
$content
</div>
<!-- /wp:column --></div>
<!-- /wp:columns -->
HTML;
wp_update_post([
'ID' => $post_id,
'post_content' => $wrapped_content,
]);
WP_CLI::log("Updated post $post_id");
}
WP_CLI::success("All posts wrapped in columns.");
});
}
- Run script in command line.
- Export modified posts from local env.
- Install WP Import PRO on destination staging site and import posts.