Drupal – Create Views for Parent Terms or Children Terms Only

Assume we have the following taxonomy hierarchy.

  • Meat
    • Beef
    • Chicken
    • Pork
  • Seafood
    • Crab
    • Fish
  • Vegetable
    • Cabbage
    • Potato
    • Tomato
  • Drink
    • Coke
    • Milk
    • Lemon Tea

 
Create a taxonomy view as follow

 

In the above view, what you need is a parent term relationship and set this in a term filter. if this term filter is empty, that means term without a parent term would be selected(Parent term only). On the other hand, set the term filter to not empty in order to get all children terms(Children term only).

Done =)

Reference: Drupal Views Taxonomy Parent Term and Child Term

9 thoughts on “Drupal – Create Views for Parent Terms or Children Terms Only”

  1. I have a view similar to this and it gives me all of the child terms that have a parent, regardless of what that parent is.. but I do not want *all* child terms – I just want those of a given parent.. I’ve tried setting the term id of the parent in the contextual filter (argument) but it still gives me all child nodes…

    Any suggestions how to do this (in D7)?

    Like

  2. Hi can you please guide how to have (PARENT) | (CHILD) |(GRANDCHILD) exposed filters that are dependent on selection of parent followed by child and the grandchild, please

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.