I am renovating an old site that has a messy custom post type. Over the years, it has accumulated redundant fields and taxonomies. I have replaced it with a new CPT that reflects the client's current business logic, and now I need to migrate the old data to the new format.
This is the process I have in mind for migrating the post metadata:
- Add both old and new CPT and related taxonomy definitions to a blank theme.
Output meta data and taxonomy terms for a sample of the old posts, and for an example of a new post. Look for patterns, and build up a
$migrationMaparray, where each element is
function translate( $oldVal ) -> $newVal
function verify( $oldVal, $newVal ) -> $ok
Dry run: Loop over the old CPT and make sure that all
var_dumpthe output, a translated version, of each post, and make sure it looks good.
Do it again, but this time run the outputs through
wp_insert_postto complete the migration of the CPT data.
And then, repeat the process for taxonomies.
Has anyones else done this? Does anyone know if there is a simpler / easier way?