Skip Navigation

[Resolved] Custom search form with grouped related children results

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 3 replies, has 2 voices.

Last updated by Luo Yang 1 year, 12 months ago.

Assisted by: Luo Yang.

Author
Posts
#2550995
toolset.jpg

Hello,

I have read the documentation and I am a bit experienced using toolset blocks but still I cannot figure out how to do what I want.

I have a custom post type "Products" and a custom post type "Product Families".
Product Families are related to Products with a 1-to-many relationship ( 1 Product Family have many Products)
Products also have several taxonomies (e.g. Type, Size, etc)

I am trying to build a search form that will display Product Families (parent) and their related Products (children) as a group, i.e.

- Product Family A
-- Product AA
-- Product AB

- Product Family B
-- Product CC
-- Product CD

I want to display only the results that will meet certain criteria (filters) based on Product taxonomies, e.g. select a Product Type taxonomy from a dropdown element and then display the resulting Product Families and their respective Products that belongs to that taxonomy.

If the Product Family is not related to any Product with the specific taxonomy (Product Type) selected by the user, I don't want to include it in the results.

I have attached an image that illustrates my case.

Please let me know If it is possible to do what I described using Toolset and if it is indeed, please provide a link to the appropriate documentation or a short answer.

Thanks a lot.

#2551517

Hello,

In your case, you can setup a post view with search form, filter result with those filters:
1) Post type relationship between "Product Family" and "Product", it should output the select dropdown, like below:
- Choose one family
- Product Family A
- Product Family B

2) Taxonomy Type, Size, etc

And you can enable option "Show only filter options that would produce results", so filters will output only those options can have results.

See below test site:
Login URL:
hidden link

Result page:
hidden link

You can see view settings here:
hidden link

More help:
https://toolset.com/course-lesson/creating-a-custom-search/#steps-for-creating-custom-searches

#2551557

Hello,

I get your example but what I am looking for is very different.

The main difference is that the product family is not listed in the results.

#2554063

There isn't such kind of built-in feature to group search result by parent posts, but you can display the parent post information in the search result, for example, edit the post view:
hidden link
In view's loop, display the parent "Product Family" post information
See the result here:
hidden link