Skip to main content

Why does this work to remove a single term?

$existingTerms = wp_get_post_terms($postID, 'custom_taxonomy');
        $newTerms = array();
        foreach($existingTerms as $term) {
            if ($term->slug != 'remove_this_term') {
                $newTerms[] = $term->term_id;
            }
        }
wp_set_post_terms($postID, $newTerms, 'custom_taxonomy');

But this doesn't?:

wp_remove_object_terms($postID, 'remove_this_term', 'custom_taxonomy');

Am I misunderstanding what wp_remove_object_termswp_remove_object_terms does?

Why does this work to remove a single term?

$existingTerms = wp_get_post_terms($postID, 'custom_taxonomy');
        $newTerms = array();
        foreach($existingTerms as $term) {
            if ($term->slug != 'remove_this_term') {
                $newTerms[] = $term->term_id;
            }
        }
wp_set_post_terms($postID, $newTerms, 'custom_taxonomy');

But this doesn't?:

wp_remove_object_terms($postID, 'remove_this_term', 'custom_taxonomy');

Am I misunderstanding what wp_remove_object_terms does?

Why does this work to remove a single term?

$existingTerms = wp_get_post_terms($postID, 'custom_taxonomy');
        $newTerms = array();
        foreach($existingTerms as $term) {
            if ($term->slug != 'remove_this_term') {
                $newTerms[] = $term->term_id;
            }
        }
wp_set_post_terms($postID, $newTerms, 'custom_taxonomy');

But this doesn't?:

wp_remove_object_terms($postID, 'remove_this_term', 'custom_taxonomy');

Am I misunderstanding what wp_remove_object_terms does?

Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
deleted 1 character in body
Source Link
Eckstein
  • 1.1k
  • 4
  • 27
  • 52

Why does this work to remove a single term?

$existingTerms = wp_get_post_terms($postID, 'custom_taxonomy');
        $newTerms = array();
        foreach($existingTerms as $term) {
            if ($term->slug != 'remove_this_term') {
                $newTerms[] = $term->term_id;
            }
        }
wp_set_post_terms($postID, $newTerms, 'custom_taxonomy');

But this doesn't?:

wp_remove_object_terms($postID, 'remove_this_terms''remove_this_term', 'custom_taxonomy');

Am I misunderstanding what wp_remove_object_terms does?

Why does this work to remove a single term?

$existingTerms = wp_get_post_terms($postID, 'custom_taxonomy');
        $newTerms = array();
        foreach($existingTerms as $term) {
            if ($term->slug != 'remove_this_term') {
                $newTerms[] = $term->term_id;
            }
        }
wp_set_post_terms($postID, $newTerms, 'custom_taxonomy');

But this doesn't?:

wp_remove_object_terms($postID, 'remove_this_terms', 'custom_taxonomy');

Am I misunderstanding what wp_remove_object_terms does?

Why does this work to remove a single term?

$existingTerms = wp_get_post_terms($postID, 'custom_taxonomy');
        $newTerms = array();
        foreach($existingTerms as $term) {
            if ($term->slug != 'remove_this_term') {
                $newTerms[] = $term->term_id;
            }
        }
wp_set_post_terms($postID, $newTerms, 'custom_taxonomy');

But this doesn't?:

wp_remove_object_terms($postID, 'remove_this_term', 'custom_taxonomy');

Am I misunderstanding what wp_remove_object_terms does?

edited tags
Link
fuxia
  • 107.1k
  • 38
  • 255
  • 459
Source Link
Eckstein
  • 1.1k
  • 4
  • 27
  • 52
Loading