[Closed] Create a Filter view by custom taxonomy that shows only the sub category terms
This support ticket is created 4 years, 5 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.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
I was wondering if a filter view by custom taxonomy that shows only the sub category terms possible to create with the Toolset view plugin.
I am planning to create a site that has a Custom Post Type 'Events' and a custom taxonomy called 'Event Categories'.
The 'Event Categories' will have 2 levels (parent level & a secondary level), example below.
Infants (<- parent level)
- drop ins
- after school programs
Adults (<- parent level)
- camps
- fitness
Say I want to create a page called 'Infants', and I would like to create a filter view by custom taxonomy that shows only the sub category terms from the 'Infants' parent category level.
So excluding the parent level term name 'Infants' and excluding the 'Adults' parent level + the 'Adult' sub categories, ONLY showing 'kids dropins' + 'after school programs' terms in checkbox fields.
I know by default, it shows all the category terms in the filter view, but is there a way to ONLY show the sub category terms from one of the parent level category or somehow hide/exclude the ones that I don't want to show in the filter view?
I have attached an image that demonstrates how I would want to look like.
Unfortunately no this is not possible to achieve because you are not able to create a filter to filter out the Parent terms and just display the child terms.
What you can do is to use a select field which I believe would display your child/parent terms like below.
Parent A
-Child A
-Child B
Parent B
- Child C
Given that the Parent and Child Terms are one Taxonomy there isn't a way to separate them into Parent and Child.
Also, since I would like to exclude specific taxonomies in the filter/search, is there a way to hide/exclude posts from the search result that are labelled with taxonomies I want hidden ?
Parent A
-Child A
-Child B
Parent B
- Child C
Say I want to only show 'Child A' & 'Child B' in the filter/search, then I would want to display posts that are labelled with 'Child A' & 'Child B' in the search result. Is there a way to do that?
The code in the link below is only to exclude taxonomy terms that you don't want to be added to the filter at all.
Also, since I would like to exclude specific taxonomies in the filter/search, is there a way to hide/exclude posts from the search result that are labelled with taxonomies I want hidden ?
Are you building your search using the Toolset Block editor ? Or are you creating it using the Classic editor by going to Toolset -> Views -> Add New.
Please let me know so that I can provide the instructions.
Thanks,
Shane
Yes, I want to exclude taxonomy terms that I don't want to be added to the filter, would that code work?
I am building the filter/ parametric search with the Classic editor 'Toolset View'.
Given that you are using the Classic editor you can try this:
1. Go to your view and edit it.
2. Scroll to the section that says "Custom Search Settings "
3. Select "Let me choose individual settings manually"
4. Then go to "Which options to display in the form inputs"
5. Finally Select " Show only available options for each input"
Once you've done this please let me know if only the Posts that are for the available taxonomies on your search appear.
I've used the code from this article (https://toolset.com/forums/topic/exclude-a-taxonomy-from-a-search/). The code works to hide/exclude taxonomy terms in the parametric search filter, so ONLY displaying 'Parent A' child terms ('Parent A Child 1' + 'Parent A Child 2') in the taxonomy filter and hide the rest (which I want).
Parent A (HIDDEN)
- Parent A Child 1
- Parent A Child 2
Parent B (HIDDEN)
- Parent B Child 1 (HIDDEN)
- Parent B Child 2 (HIDDEN)
Parent C (HIDDEN)
- Parent C Child 1 (HIDDEN)
- Parent C Child 2 (HIDDEN)
For the search result, I want to exclude some terms from the search result.
I want to hide/exclude posts labelled with taxonomies I have hidden. So ONLY displaying posts labelled with the terms Parent A Child 1, Parent A Child 2.
I've found this article (https://toolset.com/forums/topic/exclude-some-taxonomy-terms-from-filter-search/) that excludes posts labelled with certain taxonomy terms from the search result using a filter hook (wpv_filter_query) added to the functions.php file.
It does work as I wanted to, where it only displays posts labelled with the term Parent A Child 1, Parent A Child 2.
Is there a simpler method to do this in the Toolset View interface without having to do this entirely through code?