Taxonomy in Contextual filters for Views


I cloned the existing default view for taxonomy/term/%, removed all the contextual filter already existing, and then:

  • I added a new relationship, "Content: Taxonomy terms on node."
  • I added a new context filter, "Taxonomy vocabulary: Machine name," for which I didn't change any setting. (The Views module already selected the relationship I defined before.)
  • I added a new context filter, "Taxonomy term: Term ID."

For the "Taxonomy term: Term ID" filter I used the following settings.


I changed the path for the view to "test-term/%" and removed the feed.

The setting page for the view, once done the changes I described, appears as in the following screenshot; I highlighted the parts that are different from the setting page for the view I cloned.


What I obtained is a view that shows the nodes containing the terms from the vocabulary for which I pass the machine name as first argument.

For http://tero.local/dr71/test-term/tags ("tags" is the machine name for a vocabulary I defined in my test site), I get the following result.


For http://tero.local/dr71/test-term/tags/tags (the second "tags" string is the name of a taxonomy term that the "tags" vocabulary has), I get the following.


I didn't find any way to filter out the duplicates that appear in the first case, though. This is would happen only for those vocabulary that allows the users to select more than one term per node.

The relationship with the taxonomy terms is necessary as the view is about nodes; without the relationship, it would not be possible to use "Taxonomy vocabulary: Machine name," and "Taxonomy term: Term ID" as contextual filters. You can check it: If you remove that relationship, you will not able to add them as contextual filters.

Similar questions

How to get Taxonomy Menu working properly with Contextual Filters in Views?
I can't get taxonomy menu links working properly with contextual arguments in Views. This is what I have done: 0) I create a menu called: Catalog menu 1) I create a Vocabulary called: Catalog terms and in the Taxonomy menu area I set Catalog menu for the Menu location (I have Taxonomy menu module enabled which allow me to do this) 2) I the Catalog ...
how to filter taxonomy vacobulary using views contextual filters
I have taxonomy vocabulary I will be passing view arguments as parent term1. So the output should be (child term1,child term2,child term3). Please let me know how to achieve this using views contextual filters Thank you very much for your help!
Using taxonomy terms alias in views contextual filters
I hope you can help me out with this. I have created a simple view with an argument. I use that argument to filter (contextual filter) the content of the view. I already know I can use that argument as a taxonomy term ID and as a taxonomy term name, which means I can get my view loaded as: or ...
Views: Multiple Contextual Filters (Taxonomy)
My view should be filtered by multiple taxonomy terms, e.q. : show me all "events" that are tagged by the terms "show", "age over 40" and "outside". While I can filter by one taxonomy term just fine, it is not working with multiple terms. View Settings: Relationship: Taxonomy terms on node Contextual Filters: (term) Taxonomie-Term: Name Allow multi...
Views with both menu and jump menu taxonomy terms as contextual filters
I have a page view with a category taxonomy menu and a city jump menu. I want them to work together so that if the view shows all content and a user clicks on a category in the menu, the view will be fitered by category and if the user chooses a city in the jump menu, the view will be filtered by city. If a category has already been chosen and the ...
Using Views' Contextual filters in a Panel for one taxonomy term
I have one taxonomy term, Country, which is linked to another, People. One people is from one country. How can I make a view in my Panel, using Contextual filters, in order to show the specific view I prepared for "Country" ? I tried to use contextual filters to do so, and it works when I use the preview with the Country ID - but not in Panels.

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.