I’m currently preparing a structure for a medium-sized project that is based on WordPress.
The project comes with multiple custom post types, i.e. Hotels, Villas, Apartments and more.
Each of them is going to be grouped by one of the 3 cities (with more to come in the future). For that, I’m going to create a new “City” taxonomy that will be assigned to each post type that will need it (Hotels, Villas, Apartments). I was thinking about going for a radio meta field here but I’m truly worried about the meta_query performance and I believe that this specific case truly suits the taxonomy concept.
However, some of those post types will also need to be grouped by a “District”. Naturally, each city will come with an individual list of districts i.e. London has different districts than Manchester. So, ideally, once someone selects the “City”, only that city related districts are going to pop-up as available to choose. This could be done with meta fields but, yet again, I’m worried about the meta query performance so I guess I’d be better off creating it with taxonomies. I guess I’d also have to tweak it to allow a single (radio) selection.
So I have a couple of options:
Create a separate taxonomy for “Cities” and a separate taxonomy for “Districts”. However, to make it easier to manage, each city from the “Cities” taxonomy would have to be re-created as a parent taxonomy in “Districts” so it’s all nicely organized. The solution is also less ideal than meta fields because I cannot make any sort of “conditional” neighborhood display (based on the city selection) so all of them would have to be displayed at once.
Create one “Locations” taxonomy where districts would be created as child terms. However, this creates one, huge taxonomy and there would also be trouble of “forcing” the parent term selection (since it’s not natively handled).
The issue in both would for sure be to make it a single (radio) selection and, ideally, once someone selects a child term, the parent is being selected automatically. Otherwise, if someone picks just the child term, WordPress displays it individually in the taxonomy metabox and you have no idea what is that specific child meta related to.
Or maybe there is some other, better way of handling this?
I’d love to hear some feedback regarding this. Thank you so much!