Skip Navigation

[Resolved] How to make “Relationship Custom Search” with toolset

This thread is resolved. Here is a description of the problem and solution.

Problem:

How to setup a custom search form with post type relationships.

Solution:

You can follow our document to setup the custom search form and relationship filters.

Relevant Documentation:

https://toolset.com/course-lesson/creating-a-custom-search/

This support ticket is created 3 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

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 23 replies, has 2 voices.

Last updated by kimJ-2 3 years, 7 months ago.

Assisted by: Luo Yang.

Author
Posts
#1779413
customsearch-3.JPG
customsearch-2.JPG
customsearch-1.JPG
relationship-2.JPG
relationship-1.JPG

Hi,

Im trying to make "Relationship Custom Search" referring to

hidden link
and
https://discover-wp.com/register/?site_type=713&layouts=yes
and YouTube.

I want to make "Finding Restuarant Homepage" that can find "RESTUARANT" according to "CITY" and "FOOD TYPE".

I will show you my setting in image and diagram(attached).

In these,

"CITY" = "City_Foods"
"FOOD TYPE" = "Foods"
"RESTUARANT" = "Foods_Korean" and "Foods_Japanese"

and

for the sake of readability, I have marked the questionable ones by color.

----
1. Relationship issue

"City - FoodType - Restaurant" : I want to make "Custom Search Form"

Please see the "relationship-1.JPG" and "relationship-2.JPG"

I want to make a "Custom Search Form" resulting in a table of contents by selecting them in order.

First, we can select "CITY" and then "FOOD TYPE".

Since "Korean Restuarant" and "Japanese Restuarant" are everywhere in "Seoul" or "Daegu", so I'm setting Relationship(City_Foods - Foods) in parallel.

If someone chooses "Seoul" or "Daegu", he can choose "Korean Food Type" and "Japanese Food Type" and

finally, he can search "Korean Restaurant"(If he chooses "Korean Food Type" in the previous step)

To implement this, how can I modify it?

----
2. Custom Search contents issue

Please see the "customsearch-1.jpg", "customsearch-2.jpg" and "customsearch-3.jpg"

I did set up but I can't find "Post Source" came from "Foods_Korean" and "Foods_Japanese"

I can't get the "Foods price"(customsearch-3.jpg) content in View ( customsearch-1.jpg and customsearch-2.jpg )

What's wrong..??

I made it by referring to the "Demo site", "Study course", and Youtube you sent, but it doesn't work well.

Because I don't know much about it yet.

I desperately need your help.

thanks for helping me.

I always respect and appreciate your kindness and cleverness.

Have a good day 🙂

#1780839

Hello,

I suggest you try with two custom post types + one custom taxonomy, for example:
1) two custom post types:
- City
- Restuarant, with custom field
Setup one-to-many relationship between "City" and "Restuarant"

2) Create a custom taxonomy "Food type", register it to post type "Restuarant".
So you will be able to add more terms into taxonomy "Food type" easily.

3) Create a page, with a view block:
- Query "Restuarant" posts,
- Filter by parent "City" + taxonomy "Food type"
- In the loop, display "Restuarant" post information

For the problem "Foods price", where and how do you setup the custom field "Foods price", if it is a custom field of "Restuarant" post type, you should be able to display within above view's loop.

Please let me know if you need more assistance for it.

#1780917

Thanks Mr.Loo Yang.

I'm reviewing the first of your suggestions.

According to your advice,

I have to make one-to-many relationship between "City" and "Restuarant".

So it seems that if someone select a city, he can see "Restuarant" from "Custom Search",

where he can choose the desired "Food Type".

But in my opinion, If I make it this way,

I think I have to create a separate page for each "CITY"

someone(visitant) enter "CITY"'s page,

If so, it seems that he would be able to find "Restaurant" by accessing the "City" page

to find the restaurant he was looking for, searching for the "Food type" he wanted.

Did I understand correctly?

If what I understand is correct, your idea is really great.

But what I intended is,

In one page, I want to create something that lets he find "Restuarant" by selecting "City" and "Food type" sequentially.

As I said earlier, just as there are "hamburger" in Seoul or Daegu.

Whether he choose Seoul or Daegu, I want to make it possible to choose a hamburger option.

In other words, options "City" in Seoul and Daegu include options such as "hamburger" or "chicken".

Both Seoul and Daegu "City" options include hamburger and chicken "Food Type" options.

Hamburger Restaurant in Seoul and Daegu are different store, but they are included in "Hamburger" title.

In other words, even if he choose Seoul or Daegu, I want to make it possible to find a hamburger restaurant in Seoul or Daegu

(whatever he chose "City") by allowing him to choose a hamburger option(Food Type).

I hope my opinions are well communicated to you.

Others you suggested are still under review.

Thank you very much.

#1780973
search.JPG

I have attached a picture.

Please see the picture.

Suppose I visited a homepage that tells where fast food restaurants in the world

First, I live in Korea, so I choose Korea.

Second, Choose the type of fast food I want to eat. I choose hamburger.

third, all hamburger restaurant in Korea are searched.

fourth, but since I am traveling to the USA next week, I want to search for American chicken to eat.

Last, I choose USA and Chicken. I got the all result ot them in one-page.

thx Mr. Luo Yang 🙂

#1780995
custom-search.JPG

That is built-in feature of Toolset Blocks plugin, you can find and select your view block, in section "Custom Search", enable option "Show only filter options that would produce results", see my screenshot Custom-Search.JPG

#1781077

I'm trying to make something you helped,

but I still don't understand.

Can I ask for an example like last time?

Even if I watch the video,

I can't understand the content well.

How do I make a secreat reply for PW?

thx Mr.Luo Yang

#1781079

Please provide your website credentials in below private message box, also point out the problem page URL and view URL, thanks

#1781139

Thanks for the details, I can login your website, will update here if find anything

#1781283
relationship-filers.JPG

I have setup a demo in your wesbite:
1) Setup three post types:
- City
hidden link
- Food type
hidden link
- Food
hidden link

2) Setup many-to-many relationship between "City" and "Food type"
hidden link
Setup many-to-many relationship between "Food type" and "Food"
hidden link

3) Setup a post view:
hidden link
- Query "Food" posts,
- Filter by post type relationships
See my screenshot relationship-filers.JPG
- In view's loop, display food post information

Test above view in front-end:
hidden link

It works fine.

You can setup the price field into post type "Food", so you will be able to display it in above post view's loop too.

#1781307
thankyou.JPG

Thank you very much.

I think you are a genius.

Despite your genius idea,

There was something I wanted to implement more if it was tricky.

Please see the image what I attached

Looking at item "Food Types", It looks like "Food Types" is disabled.

Even if someone doesn't select a city, I was thinking of showing the search results accordingly

when he only selects "Food Types", not "City".

What else can I fix here?

I was conceiving it according to your advice, but it seems difficult with my ability.

If it's not difficult, could you help me with this?

Again, I praise you for your cleverness and talent.

Thank you so much.

#1781973
cap2.JPG
cap.JPG

Hi

Mr.LuoYang

How to fix the "Search food" view what you made on the Test page?

please see the screenshot

plus,

I've tried making it imitate you, but I don't see "Custom Search Filter" for "Cities" and "Types".

thx

#1782345
3.JPG
2.JPG
1.JPG

Hi, Mr.Luo Yang

I finally got the results I wanted.

I think I need to make one more correction.

Please see the screenshot in order.

If I choose "Foods States" and then "Foods Cities" but I try to change "Foods Cities",

Items in "Foods Cities" are not affected by "Foods States".

All of the items in "Foods Cities" are displayed.

Is there anything I need to fix?

--

plus,

Can I change the font size in "Custom Search Text?"

It's too small.

thank you so much.

#1783513

Please point out the problem page URL, I need to test it in a live website, thanks

#1783547

thx, Mr.Luo Yang.

hidden link

here is the problem page URL.

ID and PW are the same as before.

thx!

#1783581

Thanks for the details, I have done below modifications in your website:
1) Edit the page
hidden link
Select view block, in section "Content Selection", disable option "Foods States" and "Foods Cities"

Test it in front-end:
hidden link
It works fine, and since you are using post type relationships, it is not recommended to select multiple post types, it might conduct unexpected result, see the demo you mentioned above:
hidden link

It is based on post type relationships:
States-> Cities-> Properties

2) You can use CSS codes to "Custom Search" Text, for example:

input[name="wpv_post_search"]{
/** Here setup your custom CSS codes**/
}

More help:
hidden link

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.