WP-CLIでドメインの置換を行う方法

基本コマンド


wp search-replace --dry-run 'https://example.com' 'https://example.net' --all-table

上記コマンドはhttps://example.comhttps://example.netに置換するコマンドになります。
--all-tablesオプションを付けると全てのテーブルを対象にすることができます。
--dry-runオプションを付けると実行前の確認ができるので、--dry-runで確認をして問題なければこのオプションを削除して実行します。

wp-envの場合


npm run wp-env run cli "wp search-replace --dry-run 'https://example.com' 'https://example.net' --all-table"

参考