I have entity reference field to a taxonomy vocabulary on a node, which is a multi value field.

In Views, how do I list related nodes that share only the first selected category?

Example: Suppose I have selected "category3" and "category4" for a node. I want to show other nodes which have selected "category3".

  • the first category selected for that node not in the category list. If the selected categories are banana and pear then banana is the first category. field_category['und'][0]['target_id'] = 3 (banana id) and field_category['und'][1]['target_id'] = 4 (pear id)
    – Ahmad
    Aug 24, 2015 at 5:27

1 Answer 1


You should be able to set up something like what you are after with the following steps:

  • Create a view of content (nodes)
  • Add a contextual filter for NID with a that gets it's default value from "Content ID from url" (presuming the related products are to appear on the original products own page).
  • Add a relationship on field_category, call it something like "category", require this relationship
  • Add a filter of field_category:delta, value = 0
  • Add a relationship of "Content using field_category", require this relationship, use relationship: category, call this relationship something like "related"
  • Add another contextual filter that's also for NID with a that gets it's default value from "Content ID from url", use relationship: related, tick "Exclude" in the "More" fieldset at the bottom.
  • Now when you add your fields use relationship: related.
  • This is not working
    – Ahmad
    Aug 25, 2015 at 13:52
  • Hi @Ahmad, care to be a bit more specific? What does this output when you try it and how does that differ to what you expect? Aug 26, 2015 at 14:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.