Is it posiible to expose taxonomy term weight in node object ?

I need to sort nodes using EntityFieldQuery by term reference field, but weight is not exposed to node object so i can say for example

->fieldOrderBy('field_custom_terms', 'weight', 'ASC');

and sort nodes by weight of terms.

1 Answer 1


No, this is not possible. You can only order on actual field values, the term weight would require a JOIN to a non-field table and EFQ is not capable of doing that.

You will have to create a manual SQL query to do this. Note that Drupal by default maintains the node <-> term associations in the taxonomy_index table, that one is easier and more reliable to query than a field data table.

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.