Skip to content

Instantly share code, notes, and snippets.

@fida02
Last active March 4, 2022 19:50
Show Gist options
  • Select an option

  • Save fida02/c196ccd069884bfcd8f5d0b64ee3fcca to your computer and use it in GitHub Desktop.

Select an option

Save fida02/c196ccd069884bfcd8f5d0b64ee3fcca to your computer and use it in GitHub Desktop.
Change custom post type name, custom taxonomy name and runc the function once
<?php
/**
* Migrate data from v2.0.4 to v2.1.0
*
* run once
*/
function fida_migrate_data() {
if ( get_option( 'fida_migrate_data_204' ) < 1 ) {
global $wpdb;
$wpdb->update( $wpdb->posts, ['post_type'=>'New_Post_Type'] , ['post_type' => 'Old_Post_Type'] );
$wpdb->update( $wpdb->term_taxonomy, ['taxonomy'=>'New_Taxonomy'] , ['taxonomy' => 'Old_Taxonomy'] );
update_option( 'fida_migrate_data_204', 1 );
}
}
add_action( 'init', 'fida_migrate_data' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment