Edit: Sorry for the pointless title :-/ It should be "Search for values in child posts but show parent post"
Hi there
We build a website for a travel agency. They offer multiple tours. The tours are a CPT called "Tours".
To each tour, we need to assign dates with prices. We thought of making a new CPT named "Dates". We planned to connect the dates with the tours by using a relationship (one-to-one). First question: is that the correct way to do it or is there another better option?
Second question: We would like to integrate a search view that allows to search for dates. In the results, it should display the tours that have related posts that lie within the selected range. Is that possible to achieve?
Thank your very much for your help.
Best,
Marcial
Hi Marcial,
Thank you for contacting us and I'll be happy to assist.
> To each tour, we need to assign dates with prices. We thought
> of making a new CPT named "Dates". We planned to connect
> the dates with the tours by using a relationship (one-to-one).
> First question: is that the correct way to do it or is there
> another better option?
- Using a separate CPT for dates is one way of doing this, but it is not the most natural way. It will mean that you'll not be using Toolset's own date field and date filtering features and you'll end up doing more work than necessary.
A simple way would be to use two "Date" type fields (one for the start and the other for the end), directly attached to the CPT "Tours".
> Second question: We would like to integrate a search view that
> allows to search for dates. In the results, it should display the
> tours that have related posts that lie within the selected range.
> Is that possible to achieve?
- Once you'll have the tour's start and end date stored as custom field values in its own CPT, it would be possible to create custom search form in the view to include a date range picker.
( ref: https://toolset.com/documentation/user-guides/date-filters/ )
Visitors will be able to use that to see only tours, where the start and end dates fall inside the selected date range.
I hope this helps and please let me know if you need any further assistance around this.
regards,
Waqar