Hello,
Sorry for my english. On my site, I have courses that is classified into category and subcategory (taxonomy).
I have created a view and would like to use this same view in several pages of the site by filtering the results on some category.
It works, but I would like to display in these pages also a manual filter or the visitor could refine the filter with the subcategories. But when I use the filter query via the shortcodes, I no longer have the option to use the category field taxonomy in the search form, it is grayed out.
How can I automatically filter a view on a category (via shorcode) AND display a custom filter field in the page where the user can choose the subcategories?
Thanks for your help
Hello,
You can add one filter on same taxonomy in the custom search form.
In your case, you might consider custom codes, for example:
1) Setup the view block and custom search form normally:
https://toolset.com/course-lesson/creating-a-custom-search/
2) Use filter hook wpv_filter_query to customize view's query as what you want in different pages:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query
Thank you for your response.
It might be a stupid question, but where should I put hook wpv_filter_query, where exactly?
You can follow our document to create a code snippet, and put the your custom PHP codes into it:
https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/
I tried to follow the different instructions, but it doesn't work. I can't.
Say I have categories (taxonomy) like this:
• Cat01
o CAT01-A
o CAT01-B
o CAT01-C
• Cat02
o CAT02-A
o CAT02-B
o CAT02-C
• Cat03
o CAT03-A
o CAT03-B
o CAT03-C
I create a view (vue1) with a filter on the categories (taxonomy)
Then I create a page "Page cat 01" and I put my view (vue1) in it.
I do not understand what I should put or or so that in my page "Page cat 01", I want see all the data which are in the category "Cat01" and all its children (cat01-A, cat01-B, cat01- C) I would like my search filter to offer me only the subcategories of cat01 (cat01-A, cat01-B, cat01-C)
Since it needs custom codes, please provide a test site with the same problem, also point out the problem page URL and view URL, I need to test and debug it in a live website, thanks