WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

From my understanding (and before trial and error),

wp_set_object_terms( 'post_id', 'add_this_term', 'in_this_taxonomy');

But from the Codex, apparently adding the term will overwrite any other terms that are set for that post and that taxonomy?

Is this right? What if the terms are nested?

share|improve this question
up vote 5 down vote accepted

wp_set_object_terms() has a fourth argument called append. Setting that to true during the call should add the term without unsetting the already set terms.

wp_set_object_terms( $post_id, 'add_this_term', 'in_this_taxonomy', true);
share|improve this answer

You can check to see what currently is in the term by using wp_get_object_terms(), you can run logic on this and decide what to put into the database, and whether you're amending the current data or creating entirely new data.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.