Programmatically save taxonomy terms
You can programmatically save a taxonomy term using taxonomy_term_save(). To save multiple terms, create an array of terms and loop through them running taxonomy_term_save() for each iteration.
Why would you want to programmatically save taxonomy terms?
It is good practice to do code based development and automate changes in a deployment module. This saves you from repeatedly adding taxonomy terms on site, which saves time and reduces the chance of human error.
In the following code snippet, change term1 and term2 to your actual terms. Also change $term->vid to the ID of the vocabulary you are saving the terms to.
New comments for this tutorial have been turned off.