I found the answer, you need to use wp_set_object_terms to set the terms of object of a taxonomy,
wp_set_object_terms( $object_id, $terms, $taxonomy, $append);
Where, $append can be true
or false
, if true, the tag will be appended to existing tag, if false, the tag is replaced.
In my example,
wp_set_object_terms( $object_id, '2 Business Days', 'pa_dispatch' , false);
Here, the pa_dispatch
is the woo-commerce taxonomy.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…