I have 2 post types: "Room" and "Vacation for Sales" in the relationship one-to-many.
Post type "Room" has custom field "Kind of Room" (Apartment, Villa, ...). With post type "Room", I created some posts, for example: "A Resort Apartment", "A Resort Villa", "B Resort Apartment", "B Resort Villa".
In the view at the archive page of "Vacation for Sales", I want to create a search field by custom field "Kind of Room" (from "Room" posts), so that I only see "Apartment", "Villa". When I choose "Apartment" and search, it will just show some post "Vacation for Sales" connecting with "A Resort Apartment", "B Resort Apartment".
How can I do that?
Is there any documentation that you are following?
Here's a basic roadmap to achieve it using Toolset:
- Firstly, ensure that a one-to-many relationship between your "Room" and "Vacation for Sales" post types is correctly established. You can confirm this by navigating to the Toolset dashboard, and selecting Toolset -> Relationships.
- Once the relationship is set, the next step is to create a new View that will display your "Vacation for Sales" posts on the archive page. To do this, go to Toolset -> Views, click on "Add New" and select "Vacation for Sales" as the post type that the View should display.
- Finally, add a search field to your newly created View. This search field will filter the displayed posts based on the related "Room" post's "Kind of Room" custom field. To do this, click on the "Search" section of the View editor and then click "Add a search field". From the list of available filters, select the "Kind of Room" custom field.
Please test it and let us know if you find any issues implementing it.
Phòng: Room
Tin bán: (Vacation) for Sales
Loại phòng: Kind of Room
I have set the relationship.
I don't see Toolset/View, but I created a view on the archive page of "Vacation for Sales". In the view on this archive, I added search filed Loại phòng (Kind of Room). But in front-end, it's empty for choosing, while it still shows in the loop.
I would like to request temporary access (wp-admin and FTP) to your site to take better look at the issue. You will find the needed fields for this below the comment area when you log in to leave your next reply. The information you will enter is private which means only you and I can see and have access to it.
Our Debugging Procedures
I will be checking various settings in the backend to see if the issue can be resolved. Although I won't be making changes that affect the live site, it is still good practice to backup the site before providing us access. In the event that we do need to debug the site further, I will duplicate the site and work in a separate, local development environment to avoid affecting the live site.
- Please make a backup of site files and database before providing us access.
- If you do not see the wp-admin/FTP fields this means your post & website login details will be made PUBLIC. DO NOT post your website details unless you see the required wp-admin/FTP fields. If you do not, please ask me to enable the private box. The private box looks like this: hidden link
Please, let me know if you need any additional details. Have a nice day.
Based on the scenario you've described and on my tests and debugging, creating the search filter by using a custom field from one custom post type (CPT) "Room" on the archive page of another CPT "Vacation for Sales" might be challenging without custom code.
By what I could investigate, there are two possible approaches to achieve what you want:
Workaround using existing CPTs: You can add the same custom field "Kind of Room" (Apartment, Villa, etc.) to the CPT "Vacation for Sales". This way, when you create a "Vacation for Sales" post, you can manually select the corresponding "Kind of Room" that it relates to. It might not be as streamlined as pulling the information directly from the "Room" posts, but it will enable you to create the search filter you desire.
Custom Code Solution: If the workaround does not suit your needs, creating a custom code to link the "Room" posts with the "Vacation for Sales" posts could provide the solution. This would require an in-depth understanding of WordPress development, PHP, and possibly JavaScript.
Please have in mind that giving support to custom code is out of the scope of this forum. The hints I shared could point you in the right direction, but we can't create, debug or modify custom code for you and it's your responsibility to maintain it.
If implementation becomes a roadblock, you might want to explore the list of Toolset Contractors for assistance: https://toolset.com/contractors/