I want to update some nodes in my system and update a particular taxonomy attach to them. I need to do this work programmatically. I have node ids and term id and want to attach this term to this particular node. What should do the trick here??
Thanks
To get the node:
To attache a term ID – note that this is very different in D7:
To add revision:
To save the node – if the node is new:
or, to save the node if it’s an existing node:
In Drupal 7, terms are attached as normal field items so field_first_name[0] means the first occurrence of the field. Don’t confuse that functionality with terms. You can add as many as terms you want.
Update: Thanks to kliker for the edit, which was unfortunately rejected. It seems I have to edit the post myself to get his changed into this answer.