Skip Navigation

[Resolved] Hide all posts Arrival date -1 day of current date +1 day of Departure date

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

Problem:
A View already contains date filters. How is it possible to add additional conditions to the same filters?

Solution:
That's not possible without custom code, using the wpv_filter_query filter to set up multiple meta query conditions.

Relevant Documentation:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query

This support ticket is created 5 years, 5 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 2 replies, has 2 voices.

Last updated by leilaG 5 years, 5 months ago.

Assisted by: Nigel.

Author
Posts
#1298617
visitor-target-date.jpg

We are already using date filter in this view to get a target date. (image attached of date filters we are using already - https://toolset.com/forums/topic/user-date-filter-search-between-dates-2/)

But would like to hide all posts that are -1day of current date and +1 day of Departure date, but when we try to add a filter the date fields don't show up because we have already used them.

#1298643

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Leila

You can only add a filter for a particular field once.

It is not possible to string together multiple conditions for the same field, that's not supported.

As you already include filters for the arrival date and departure date fields it is not possible to include extra filters for those same fields.

Your View will generate a query using WP_Query that includes conditions for the meta fields arrival date and departure date.

You *could* use the Views API (specifically the wpv_filter_query hook) to modify the query arguments to add multiple conditions for the meta fields, with an array of conditions for each field, but it is not something that can be done with the Views GUI.

See https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query for details of the API hook.

#1299287

Thank you, in that case we will ask a contractor for help with this.