Migration Tips and Tricks - mergeweb/docs GitHub Wiki

Ongoing doc of how to migrate:

This wiki page is designated to resolve some headaches in the migration process

News (Posts) Migration

  1. Install WP Export PRO plugin on source website.
  2. Create export file and download bundle
  3. Install WP Import PRO onto local environment and import posts. Posts must have title, content, author, date, and all images.
  4. Download Convert to Blocks plugin.
  5. Go to plugin settings and verify only posts will be converted to blocks.
  6. Connect to local env server via SSH (open shell in Local)
  7. Run wp convert-to-blocks start --post-type=post and follow instructions to convert all posts to blocks.
  8. 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.");
    });
}
  1. Run script in command line.
  2. Export modified posts from local env.
  3. Install WP Import PRO on destination staging site and import posts.
⚠️ **GitHub.com Fallback** ⚠️