Problem : Add checkbox filter for parent custom taxonomies.
I did research to achieve above goal but did not found anything to Add checkbox filter for parent custom taxonomies.
Solution : I have added custom dropdown field for each post type named as "Select parent category".
Now, to show parent custom taxonomies as dropdown options I have added below code.
what you need to do is - you need to add your taxonomy filter normal way but you need to add custom jQuery code to your view's filter JS box and delete the all options that are child.
Ok thanks, but I am not selecting parent taxonomy when I am creating post. I am selecting child taxonomy while adding post. Now I would like to add checkbox filter for parent taxonomy.
For example,
Restaurants ===> Parent
- Indian ===> Child
- Italian ===> Child
Watersports ===> Parent
- scubadiving ===> Child
- kitesurfing ===> Child
When I am adding post called "Taj Hotel" I am selecting "Indian" as custom taxonomy..Now I would like to add filter checkbox for "Restaurants","Watersports".
As I am not selecting parent taxonomy while creating post I will not get "Taj Hotel" when I check "Restaurants".
No - when you will add taxonomy filter normally to your views - to display all taxonomy terms, navigate to:
=> Custom Search Settings => Let me choose individual settings manually => set option "Always show all values for inputs"
So - it will display all taxonomy terms with your taxonomy dropdown, now, you should follow the way I suggested using jQuery to remove unwanted terms from your taxonomy filter drop-down.
Yes I have followed below steps
=> Custom Search Settings => Let me choose individual settings manually => set option "Always show all values for inputs"
Its working..Thanks for your support.
I have put code given by you above.
As you see in attached screenshot, There are two filter added for two different taxonomies.
When I am doing
echo "<pre>";
print_r($query_args);
I see only 1 taxonomy in tax_query that is location-theme.
I have another taxonomy as well which is location-types which I can not see when I am printing $query_args
OK - as I can see "include_children" is already set to 1, so no change needed. Now, regarding two taxonomy filter arguments, I can see that another taxonomy filter is setup using URL parameter. did you selected anything from your another taxonomy filter. If yes - it should show it, if no, it will not show it.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).
I have set the next reply to private which means only you and I have access to it.