taxonomy_select_nodes() works only if the field storage is the default one (field_sql_storage); with other field storages, or when the "taxonomy_maintain_index_table" Drupal variable is not set to TRUE
, the function doesn't return any value.
In the first case, the "taxonomy_index" table used by the function will not be populated; in the second case, the function returns an empty array.
if (!variable_get('taxonomy_maintain_index_table', TRUE)) {
return array();
}
The only way to get the list of nodes using a specific taxonomy term is using the EntityFieldQuery class, taking in consideration the following notes. I assume $query
is an instance of the EntityFieldQuery
class requiring a list of nodes; this means the following lines are being used.
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node');
If you are interested in getting all the published nodes, you should add the following line:
$query->propertyCondition('status', 1);
Differently, you will get also the nodes that are unpublished.
The EntityFieldQuery
class verifies the currently logged in user has access to the fields being checked by the query. To avoid this, if it is not desired, you should add the following line:
$query->addMetaData('account', user_load(1));
For more information about how to use the EntityFieldQuery
class see How to use EntityFieldQuery.