WordPress.org

Ready to get started?Download WordPress

Forums

wp_set_post_terms() (3 posts)

  1. samanime
    Member
    Posted 3 years ago #

    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?

  2. samanime
    Member
    Posted 3 years ago #

    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.

  3. Steveorevo
    Member
    Posted 3 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags