Forums › Forums › Search & Filter Pro › Parent / Child Taxonomy – Select parent get filtered results for all children
Tagged: child, filtering dropdown, lecture, parent, taxonomy
- This topic has 3 replies, 2 voices, and was last updated 8 years, 3 months ago by Trevor.
-
Anonymous(Private) August 18, 2016 at 10:15 pm #54987
Hi,
I have a filtering dropdown that has a list of regions in the world. There are parent regions such as Europe, Americas, etc. And the children are countries within the parent. So Europe is a parent and Germany, France, etc. are children.
In WordPress I set up a taxonomy called regions with all the values in the dropdown included in this taxonomy. The countries are assigned to a parent such as Europe, Asia, etc.
If I select Europe in the filtering dropdown, all the results should include any post that is assigned to the children. If a post is assigned to Germany it should appear when I select Europe. However, when I select Europe now, it only shows a post that was marked Europe, not a post marked with a child country like Germany.
How can I get the filtered posts to obey the parent child hierarchy I set up in WordPress.
If needed I can change my setup in WordPress as we are in the process of building a new site and can adjust so we get the right filtered results.
Thanks for your help.
Josh
Trevor(Private) August 19, 2016 at 11:04 am #55017Hi Joshua
I have some general advice I give that might be worth repeating here, so please bear with me as I go into ‘old boring teacher mode’.
WordPress is a blogging platform at heart. If you are not REALY going to use it as a blog, then disable blogging. Almost every site I now make I do this. It is a GOOD and LIBERATING thing to do. Now WordPress is more like a CMS.
DO make Custom Post Types for your site. If your theme has support to make CPTs, all well and good. Otherwise, I always use the Custom Post Types UI plugin. The all-purpose theme that I use already has its own CPT and taxonomy functions, but where I don’t use that theme (rarely, as it is so flexible), I use this plugin. When making the CPT, think CAREFULLY about what standard WordPress meta types you actually want (excerpt, trackbacks, comments, author, etc).
DON’T use the core Category and Tags taxonomies. They are not descriptive enough for SEO, are aimed at blogs (which by now you have disabled) and not specific enough (taxonomies should really be specific to one CPT). DO make taxonomies specific to your individual CPT needs, named appropriately for SEO purposes.
DON’T use hierarchies in Taxonomies (parent -> child). Use Multiple taxonomies instead. For example, a single, hierarchical Location taxonomy might become two taxonomies of Countries and Cities.
DON’T use the core WordPress custom fields meta options (where you can add your own custom fields). Instead DO install a custom fields plugin, like Advanced Custom Fields (or even the Pro version). That flexible theme that I use already comes bundled with ACF Pro, so that’s a bonus for me! Use these fields for data relating to a CPT. BTW, handy hint, DO give the field group a name that lets a third party like me see immediately/easily which CPT it belongs to.
THEN … in S&F, in the form setup, enable Auto Count, and in each form field hide empty values. It should then do what you want.
Sad, boring lecture over. LOL
Anonymous(Private) August 21, 2016 at 9:32 pm #55184Hi Trevor,
Thank you for your advice and the detailed response. I actually already practice most of what you have suggested with WordPress. I use custom post types, I create custom Taxonomies, I extensively use the Advanced Custom Fields Pro plugin, etc. It is good to be reminded of these best practices however.
When it comes to the filtering dropdown form, I can get rid of the hierarchy and create 2 separate taxonomies: Regions and Countries. However how can I then combine them into one filtering dropdown?
If you look at the Regions filtering dropdown on this page, this is exactly what I am trying to accomplish:
http://www.talend.com/partners/find-a-partner
Notice if you pick Europe, it will give you the results for all of the European countries.
I can’t use separate filtering dropdowns for Regions and Countries. It needs to work like it does on this page. So how can I combine them into one if I create separate taxonomies?
Thank you for your help!
Josh
-
AuthorPosts