Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.48 KB | None | 0 0
  1. $term_name = 'Upcoming'; //category to delete
  2. $taxonomy = 'category'; //type of taxonomy to be changed
  3. $term = get_term_by('name',$term_name, $taxonomy);
  4. $args='';
  5. $old_terms = wp_get_post_terms( $post_id_to_update, $taxonomy, $args );
  6. $new_terms = array();
  7. if ($old_terms) {
  8.     foreach ( $old_terms as $old_term ) {
  9.         if ($old_term->term_id != $term->term_id) {
  10.             $new_terms[]=$old_term->term_id;
  11.         }
  12.     }
  13. }
  14. wp_set_post_terms( $post_id_to_update, $new_terms, $taxonomy, $return );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement