I know it seems like a simple operation, but I can't find any resource or documentation that explains how to programmatically add and remove tags to a post using the post ID.
Below is a sample of what I'm using, but it seems to overwrite all the other tags...
function addTerm($id, $tax, $term) {
$term_id = is_term($term);
$term_id = intval($term_id);
if (!$term_id) {
$term_id = wp_insert_term($term, $tax);
$term_id = $term_id['term_id'];
$term_id = intval($term_id);
}
$result = wp_set_object_terms($id, array($term_id), $tax, FALSE);
return $result;
}