How do we add user date picker / filter that can search between 2 dates, when the user selects a specific date
For example:
Visitor 1 - Arrival Date 26/07/2019 Departure date 27/07/2019
Visitor 2 - Arrival Date 27/07/2019 Departure date 27/07/2019
Visitor 1 - Arrival Date 23/07/2019 Departure date 29/07/2019
We would need all 3 visitors to show when the user selects 27/07/2019 as the visitor is still present on the departure date.
Hi Leila,
Thank you for contacting us and I'd be happy to assist.
If your goal is to add a search filter that targets a "specific date" to show the available visitors, based on the separate arrival and departure date fields, you can follow these steps:
1. In the "Query Filter" section, please include filters for arrival and departure date fields, so that the arrival date field is compared as "lower than or equal to" and departure date is compared as "greater than or equal to".
Please also make sure to set the same URL parameter for both fields.
( screenshot: enlace oculto )
2. In the "Search and Pagination" section, you can include the code to show the front-end date selection field, like this:
<div class="form-group">
<label>[wpml-string context="wpv-views"]Target Date[/wpml-string]</label>
[wpv-control-postmeta field="wpcf-arrival-date" type="date" url_param="wpv-wpcf-target-date"]
</div>
Notes:
1. Please make sure to use the URL parameter value, the same as used in the "Query Filter" ( wpv-wpcf-target-date )
2. The "wpcf-arrival-date" can be replaced with the slug of either arrival or departure date field, used on your website.
I hope this helps and please let me know if you need any further assistance around this.
regards,
Waqar
That worked perfectly! Thank you so much 🙂