I have form that allows a user to filter a list of results. The filter is set using checkboxes. EntityFieldQuery is used to retrieve the results based on taxonomy ids. The problem is that if multiple checkboxes are selected, it returns all nodes tagged with any of the taxonomy ids, while I want only the nodes that are tagged with ALL of the taxonomy ids. This includes terms that are from multiple taxonomies.

These are the definition of the field conditions in my EntityFieldQuery:

$query->fieldCondition('field_section', 'value', $sections, 'IN');

$query->fieldCondition('field_features', 'tid', $params['features'], 'IN');

$query->fieldCondition('field_region', 'tid', $params['regions'], 'IN');

Basically, when checking on items in the filter it returns MORE items, when it should go the other way.

Does anyone know how to adjust the EntityFieldQuery so it does what I'd like?

Thanks in advance

  • did you already debug your $params variable? for checkboxes you need to manually traverse the values from $form_state['values'] and check if they are selected or not.
    – schlicki
    Apr 2, 2016 at 6:12

1 Answer 1


You can try:

foreach ($sections as $section) {
  $query->fieldCondition('field_section', 'value', $section);

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.