| Drupal
Show Only Specific Levels of Taxonomy in Views

One OSTraining member asked us this question:

How can I set the filter criteria so that Views shows only the second level of a taxonomy?

We've had that question from other members before, so here's a tutorial explaining how it's done.

First, you need a taxonomy that has parent and child terms, as in this example:

Drupal taxonomy with parent and child terms

Let's show you how to set up Views so that only the child terms show: Amphibians, Birds, Fish, Mammmals, Reptiles.

  • Go to Structure > Views > Add new view.
  • Create a View that shows "Taxonomy terms".
creating a Drupal view with taxonomy terms

Thanks to Beth Binkovitz for the solution to this next step.

  • Click "Add" next to Contextual Filters.
Show Only Specific Levels of Taxonomy in Views
  • Search for and choose "Taxonomy term: Parent term".
  • Click "Apply (all displays)".
  • Provide default value: check this box.
  • Type: Fixed value
  • Fixed value: enter the parent terms for your sub-terms
  • Specify validation criteria: check this box.
  • Validator: Taxonomy term.
  • Vocabularies: Choose your vocabulary,
  • Filter value type: Term name converted to term ID
  • Click "Apply (all displays)" to finish.
  • Save the filter and save your view.
  • You should now see that the parent terms are ignored:
A Drupal view with only child terms

About the author

Steve is the founder of OSTraining. Originally from the UK, he now lives in Sarasota in the USA. Steve's work straddles the line between teaching and web development.