Created
November 19, 2023 13:25
-
-
Save atanemani/7b10833a6e20c74e33971594e795d90f to your computer and use it in GitHub Desktop.
How to convert or change terms taxonomy?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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