Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $term_name = 'Upcoming'; //category to delete
- $taxonomy = 'category'; //type of taxonomy to be changed
- $term = get_term_by('name',$term_name, $taxonomy);
- $args='';
- $old_terms = wp_get_post_terms( $post_id_to_update, $taxonomy, $args );
- $new_terms = array();
- if ($old_terms) {
- foreach ( $old_terms as $old_term ) {
- if ($old_term->term_id != $term->term_id) {
- $new_terms[]=$old_term->term_id;
- }
- }
- }
- wp_set_post_terms( $post_id_to_update, $new_terms, $taxonomy, $return );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement