• Hello,

    I’m working on a custom taxon plugin and I’m making use of wp_set_post_terms().

    If I’m not mistaken, with the fourth parameter ($append) left off, it should completely replace any taxons (meaning any that aren’t in the array I pass are removed), correct?

    I’m doing something like this:

    $terms = array('a','b','c');
    wp_set_post_terms($post_id, $terms, 'my_taxon');

    It’s working, partially. Say it had the terms a, b, c, d, afterwards it’d still have a, b, c, d (when it should have removed the d.

    Any ideas?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter samanime

    (@samanime)

    Okay, so, I figured out the function was working as expected, I was just getting them wrong.

    However, now I’ve run into another problem. Is there a function that lets me easily clean up (remove) terms that are not used by any post?

    For example, say I add a term “bob”, but I accidentally meant to call it “blob”. So, I remove “bob” (after it’s been submitted and saved) and add blob. Now blob shows up in my post, but bob still exists.

    How can I clean those out?

    Thanks.

    Wondering this too? There doesn’t appear to be an API call to remove a post’s terms that I can find.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘wp_set_post_terms()’ is closed to new replies.