I would like to add a term to a vocabulary specifing the tid, already tried with Taxonomy CSV import/export and Taxonomy import/export via XML modules but both create terms with a new tid.

I even tried programmatically with taxonomy_term_save() but if i set the tid it just looks for a term with that ID.

I need to do this because then i'll import a lot of nodes, and all of them already have a relation with a term.

Any other way to do this?

2 Answers 2


tid will be assigned to the terms automatically by drupal. My suggestion is first create the terms then you can use taxonomy_get_term_by_name function to find the term and then map it to the respective node while importing.


you can add a custom number field to you taxonomy vocabulary, and save this reference id there for later use.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.