Hi! Is grouping of search results by custom field value possible? I have a country and region custom fields and i created a parametric search for this. The problem is i can't see group by in filter. I want to achieve an output something like this: Let say i put USA in my country in search then the output is
Result for USA
Alaska
- Custom post with country of USA and Alaska Region
- Custom post with country of USA and Alaska Region
- Custom post with country of USA and Alaska Region
Arkansas
- Custom post with country of USA and Arkansas Region
- Custom post with country of USA and Arkansas Region
- Custom post with country of USA and Arkansas Region
... and so on
Kindly give me an idea how to achieve this? Thanks
Dear kitsG,
You have to add 2 Views for this.
View 1. Will select all states related your search. Alaska, Arkansas etc.
in this view loop you have to add other view with attribute (example state) and value you get from loop (Alaska, ...)
View 2.
Get State from view 1 and search posts related this keyword.
structure:
View1:
start view1 loop
State title
[view2 shortocde state="state title"]
end view1 loop
View 2:
start view2 loop
post title related state title
end view2 loop
Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.
Regards,
Gen.
Hi Ghennadi,
Thanks for your reply. Im still confused on how to implement it. I have a lot of countries (all countries in the world) and a lot of states/region depends on country selected, if im going to declare it in shortcode something like [view2 shortocde state="state title"] its a lot of work.. If you can provide me the actual code that would be great.
Thanks
Dear kitsG,
I just sent you private email, please check.
Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.
Regards,
Gen.
Hi Ghennadi,
Really appreciate your support! I've implemented everything based from your test site but unfortunately i got unexpected result. I duplicates the group. Please refer to the attached image for your reference. I noticed that we are using different version of toolset. Is this has something to do with the version or i just coded it wrong? Thanks
Dear kitsG,
I’ll send you a private email right now asking you for some private information that will help me setup correct views for you. Please check your email in a couple of minutes, and if you don’t get it, let me know so I can send it again.
Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.
Regards,
Gen.
Hi Gen,
Thanks for your support! I've already fixed it. 😀