pipoulito
pipoulito

Reputation: 89

Unset post term in Wordpress

I use this to set post terms from a custom taxonomy 'mois':

wp_set_post_terms(  $post_id, array ($term_id['term_id']), 'mois' ,true);

It works fine, but how coul i do the inverse : unset a post term ? I don't want to delete the term but only unset it from the post.

Upvotes: 0

Views: 1393

Answers (1)

Abhishek Potdar
Abhishek Potdar

Reputation: 141

Here is the solution for your question. You can just use wp_remove_object_terms hook to unset the terms using post id.

Here is the example of how you can do it:

$tag = array( 5 ); // Array of terms to be unset.

wp_remove_object_terms( $post_id, $tag, 'mois' );

Upvotes: 1

Related Questions