Skip to content

Instantly share code, notes, and snippets.

@atanemani
Created November 19, 2023 13:25
Show Gist options
  • Save atanemani/7b10833a6e20c74e33971594e795d90f to your computer and use it in GitHub Desktop.
Save atanemani/7b10833a6e20c74e33971594e795d90f to your computer and use it in GitHub Desktop.
How to convert or change terms taxonomy?
<?php
function mrj_change_terms_taxonomy($term_id, $future_taxonomy)
{
global $wpdb;
$update = $wpdb->update(
$wpdb->prefix . 'term_taxonomy',
['taxonomy' => $future_taxonomy],
['term_taxonomy_id' => $term_id],
['%s'],
['%d']
);
return $update;
}
<?php
add_action( 'init', function(){
$terms = get_terms([
'taxonomy' => 'banner_pos',
'hide_empty' => false
]);
if(!empty($terms)) {
foreach($terms as $term) {
mrj_change_terms_taxonomy($term->term_id, 'content_cat');
}
}
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment