Forums › Forums › Search & Filter Pro › Combo Boxes with Parent and Children Records
Tagged: V3
- This topic has 15 replies, 2 voices, and was last updated 5 years, 8 months ago by Trevor.
-
Anonymous(Private) March 6, 2019 at 7:08 pm #204149
I have a category that has parents (Countries) and children (Cities). I’m trying to build two search options on different pages
1) Search Page 1
Show parents and children in same combo dropdown. This is working but when searching for a Parent – i.e. Argentina – I want to show ALL children under the filtered results in the combo box. At the moment, the children records are hidden since they do not contain the word Argentina2) Search page 2
I would like two combo dropdowns – first one for pulling in the Countries which are Parents. The second combo box to pull in the Cities (which are children of the parent records). I can get the first box working bit am unable to hide the parents in the second combo dropdown.Trevor(Private) March 7, 2019 at 11:03 am #204198You need to separate out groups, branches or parent/child categories into separate custom taxonomies. In the case of your form, this means you plan to use category twice, so you really need a taxonomy for countries and one for cities. In general, you can use a particular Taxonomy, such as Category, (or Tags, each Taxonomy and each Custom Field) only once in the form. This post tries to explain this a bit better (you can use a plugin to switch category terms from category to any new taxonomy that you make, so it is not so hard to do). It is a really awful preachy lecture I wrote:
https://support.searchandfilter.com/forums/topic/multiple-categories-combination/#post-55166
Sorry about the tone, but the message is right and it links to good plugins (except taxonomy switcher I think).
Taxonomy switcher is a ‘use once and remove’ type of plugin, and it uses ‘hidden’ features in WordPress that have not changed for about 2 years.
Let us say that you have Categories (as WordPress calls them) on some posts, and some of them are fruit types. For example, Apple. Now you decide to have a separate taxonomy called Fruit Type. You may have hundreds of posts with those fruit types already in Categories, and don’t want to retype them all again. Let us say the the Apple ‘term’ has an ID # of 234 (they all have ID numbers). You tell Taxonomy Switcher to move the term 234 from Categories to Fruit Types, and it does all the work for you. You can do a whole bunch of IDs at once, all you need is their ID numbers.
IF you went in to one of our forms in admin, to the Tags, Categories & Taxonomies settings tab, find the line for Categories (in this case) and use the search to ‘add’ all the ones you want to move, then you will see in the settings box all the ID numbers you need to be able to do this. So, cut them from that box and paste them in to Taxonomy Switcher.
Be wary if you have child terms though (those which have a parent), as the parent may have to be moved also.
Anonymous(Private) March 8, 2019 at 3:01 am #204321Thanks for the detailed reply. The issue is that if I have Country and City as separate taxonomies then how do I have a user select a Country in Combo box 1 and have the results in Combo Box 2 filtered based on the Country selected in Combox box 1.
i.e.
Country Taxonomy has countries of United States and Canada
City Taxonomy has cities of Miami, Denver, Toronto and VancouverProduct A has both countries and all 4 cities selected.
If the user selects Combo box 1 country as United States I’d want Combo Box 2 of City only to show Miami and Denver.
Trevor(Private) March 8, 2019 at 6:41 am #204327To enable the ‘linking’, in the General settings tab:
Set
Auto Count
(both settings) toON
And then in the Form UI:
In each field set
Hide Empty
toON
Then, whe you make a country selection, only the cities of that county will show. Our plugin does this by looking at the posts to see which cities are linked to which country.
Anonymous(Private) March 8, 2019 at 5:38 pm #204448Really sorry but still confused here. How will wordpress or your plugin know that Miami and Denver are linked to the United States unless I have a parent child relationship setup in a single taxonomy.
A post will contain multiple countries and multiple cities.
Trevor(Private) March 8, 2019 at 5:47 pm #204450Are these in a custom post type or a standard post? What is the subject matter of the posts? Whatever the post is about, in can have more than one country associated with it, and therefore more than one city? If that is the case, that would not work, I think.
-
AuthorPosts