Skip Navigation

[Resolved] Filter by sub categories

This thread is resolved. Here is a description of the problem and solution.

Problem:
Can I set up a parametric Filter by a hierarchical taxonomy, but split the parent terms and child terms in two Parametric Filters?

Solution:
This is not possible.

Views Parametric Filters for Taxonomies will always produce all Terms in the same Filter (child and parent terms)

A workaround:
1. Views will, when you insert a parametric Search by your Taxonomy, always generate a Search Filter by ALL terms (parents and children terms)

2. If you need a Front End Filter that does display ONLY terms that are Child of a given parent, it is not possible, because the View will allow the Taxonomy filter only ONCE each View.

- therefore, you need 2 Taxonomies, one acts as a parent to the other.

- Or you could neglect to use a Parametric Search and instead return Posts, in a Taxonomy View, which query Filter is set to

Select taxonomy terms whose parent is your_parent_term

.

- But this will not allow a Parametric Search, as only Post Views do allow Parametric Searches.

Relevant Documentation:
https://toolset.com/documentation/user-guides/using-a-child-view-in-a-taxonomy-view-layout/

This support ticket is created 7 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 4 replies, has 2 voices.

Last updated by Pat 7 years, 10 months ago.

Assisted by: Beda.

Author
Posts
#403257

Pat

Hello,
I'm using WC product categories and have this :
Cat1
Subcat1
Subcat2
Subcat3
Cat2
Subcat4
Subcat5

I have a Views thta dosplays products and want this view to make the following :
1. Display only Cat1products
2. Have a parametric search able to propose to filter by subcategories (only those under cat1).

The Views is located ona page.
I tried to use the parametric search but can only have Cat1 products or all products with the parametric search on all categories.

Can you help on this please
Thanks
Pat

#403364

This is not possible at the moment.

I filed such a feature request in past, but can not yet state an ETA or even if it's considered or not.

Views Parametric Filters for Taxonomies will always produce all Terms in the Filter.

What you can try is to use a second Taxonomy, which acts sort as a "child term" taxonomy.

You categorise your Products by "Taxonomy A" (parent) and also by Taxonomy B (that acts as child)
Then you create a View that lists Posts, with this Query Filter:

Select posts with taxonomy: your_taxonomy set by the parent Taxonomy View	
</Code

Also, you insert a Parametric Filter, that filters your second Taxonomy B, (which acts as child)

Then you create a second View, a taxonomy View, that queries only Taxonomy A and has a query filter as:
[php]
Taxonomy is One of these: your_term

You will then insert the first view to this taxonomy View's Loop and insert the taxonomy View to a page.

#403422

Pat

Hi Beda,
Do you mean that I need to create another taxonomy than "Product cat" ?
I was thinking that arranging the categories like explained in my previews post (cat and subcat) would be sufficient to make the sorting only on subcat.
Not sure to understand your solution. Could you clarify please.
Thanks
Pat

#403623
Bildschirmfoto 2016-06-02 um 15.11.52.png

Let me clarify.

1. Views will, when you insert a parametric Search by your Taxonomy, always generate a Search Filter by ALL terms (parents and children terms)
You can see a typical output in my screenshot.

2. If you need a Front End Filter like in my ScreenShot that does dispaly ONLY terms that are Child of a given parent, it is not possible, becuase the View will allow the Taxonomy filter only ONCE each View.

And therefore, you need 2 Taxonomies, one acts as a parent to the other.

Or you could neglect to use a Paramteric Search and isntead return Posts, in a Taxonomy View, which query Filter is set to "Select taxonomy terms whose parent is your_parent_term".

But this will not allow a Paramtric Search, as only Post Views do allow Paramtric Searches.

This is why I suggested to create 2 Taxonomies, one acts as parent to the other.

I am not sure I understand your goal, as you mentioned earlier, you want to
1. Display only Cat1products
2. Have a parametric search able to propose to filter by subcategories (only those under cat1).

Now in the last answer you mention that you want it to SORT by those terms
This is not the same.

To sort by Terms, you needto use the Ordering Setting in the View.
But only Taxonomy Views can be ordered by Taxonomy terms.
Not so Post Views.

Again you would need at least 2 Views and nest them
Here is some DOC about this:
https://toolset.com/documentation/user-guides/using-a-child-view-in-a-taxonomy-view-layout/

#403661

Pat

Hi Beda,
Thanks for your clarification.
I have managed this with an additional custom field to define the sub category ad it's working.
Regards
Pat

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.