Create a vocabulary with terms that are linked to a content type I need to create a vocabulary with this "twist": the taxonomy terms of the vocabulary are the titles of the article based on a specific content type.

This means that if I create, modify, or delete an article based on the content-type "vocabulary," the relative term in the vocabulary should be added, modified, or deleted.

Imagine I have the content type "Cars." I create different articles, one of which is "Ferrari 456", and another one is "Volkswagen Golf." I want a vocabulary called "cars" with a term for each article (e.g., one for "Ferrari 456", one for "Volkswagen Golf").
When you are creating a new node, you call taxonomy_term_save(), passing as argument the taxonomy term object $term, and using the node title for set $term-&gt;name, and the vocabulary ID to set $term-&gt;vid.
When you update a node, you first you load the taxonomy term with taxonomy_term_load_multiple(), as in taxonomy_term_load_multiple(array(), array('name' =&gt; trim($name), 'vid' =&gt; $vid)), change $term-&gt;name, and save the taxonomy term with taxonomy_term_save().
When you delete a node, you first load the taxonomy term with taxonomy_term_load_multiple(array(), array('name' =&gt; trim($name), 'vid' =&gt; $vid)), and then delete it passing $term-&gt;tid to taxonomy_term_delete().


The functions I reported needs to use the vocabulary ID; this means that the module you are writing needs to save in a Drupal variable the ID of the vocabulary it created, or to ask to the user the vocabulary name for the vocabulary that needs to be used. In the second case, and in the case the module stores the vocabulary name, code similar to the following one should be used to get the vocabulary ID:

$vocabulary = taxonomy_vocabulary_load_multiple(array(), array('name' =&gt; trim($name)));
$vocabulary = reset($vocabulary);
$vid = $vocabulary-&gt;vid;


The code needs to be changed for Drupal 8, as the conditions (the second parameter of taxonomy_term_load_multiple(), and taxonomy_vocabulary_load_multiple()) will be removed in Drupal 8.