Accessing taxonomy custom field values (Drupal 7)? I've added a new vocabulary to Taxonomy, and then proceeded to add several custom fields to that new vocabulary. In the taxonomy_term_data table, I see the values for the tid, vid, name, description, format, and weight fields. It also looks like there are now a couple of new tables in the database that are related to the new custom fields that I created for the new vocabulary (i.e. field_data_field_taxonomy_cip_code). The values in the new table are entity_type, bundle, deleted, entity_id, revision_id, language, delta, field_taxonomy_cip_code_value, and field_taxonomy_cip_code_format. There's nothing that I can see on the surface that would allow me to relate the two tables together.

How would I go about pulling the additional custom field values along with the new vocabulary values?
If you load the taxonomy term with taxonomy_term_load(), you will get any custom field you added to the vocabulary.

I created a vocabulary to which I add a boolean field (field_test_boolean); I added a taxonomy term to that vocabulary, and then executed the following code. (22 is the taxonomy term ID for the taxonomy term I created.)

$taxonomy_term = taxonomy_term_load(22);
dsm($taxonomy_term);


The output shown by dsm() is the following one.



If you want to get the field value for the language currently set for the field, you should use the following code.

$values = field_get_items('taxonomy_term', $taxonomy_term, 'field_test_boolean');


If you need to find the taxonomy terms for which the custom field contains specific values, you should use the EntityFieldQuery class.

  $query = new EntityFieldQuery();
  $entities = $query-&gt;entityCondition('entity_type', 'taxonomy_term')
    -&gt;entityCondition('bundle', 'fields_test')
    -&gt;fieldCondition('field_test_boolean', 'value', 1, '=')
    -&gt;execute();

  if (!empty($entities['taxonomy_term'])) {
    $taxonomy_terms = taxonomy_term_load_multiple(array_keys($entities['taxonomy_term']));
  }


Note

As noticed in a comment, there is a bug that doesn't allow to use the EntityFieldQuery class for taxonomy terms. The code seems fixed in the Drupal 7 development snapshot, but Drupal 7.14 is affected by the bug.