Skip Navigation

[Gelöst] Show view results that are overlapping start- and endtime

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

Problem:
Client has start date and end date custom fields. In a custom search View they have added filters for the begin and end dates, but would like posts to be included in the results if any part of its dates overlap with the filter start and end dates.

Solution:
The trick is to compare the start date from the filter with the end date of the post, and the end date from the filter with the start date of the post.

Insert filters for the start and end dates. In the Query Filter section (you may need to use the Screen Options tab at the very top of the page to expose it) edit the filters to swap the URL parameters used by the two filters, and to make it so the the start AND end filters must be true.

Relevant Documentation:
https://toolset.com/documentation/user-guides/filtering-views-query-by-date/

This support ticket is created vor 6 Jahre, 5 Monate. 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.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

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+01:00)

Dieses Thema enthält 3 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von marcov-3 vor 6 Jahre, 5 Monate.

Assistiert von: Nigel.

Author
Artikel
#598374

So I setup a view search that show tours that will be in the chosen timeframe. I created a custom field with datepicker starttime and one with endtime. In the query filter (you can show this thru choose the "screen options" on top of your backoffice, yes that one!) I placed the starttime to UNSIGNED "LOWER THAN OR EQUAL" with URL parameter to wpv-wpcf-starttime (because this is the field created) and the starttime to "greater than or equal" with URL parameter to wpv-wpcf-endtime.

Now the tours will show when the chosen tour is equal to or within the selected timeframe. Would it be possible to also show products when someone chooses the date from before the availability in our example 1 april. So the customer selects the 31 march to 7 april timeframe. This will be a outside the begintime but will end within the end time. Now it will not show anything because the begin time is "lower than" 1 april, see attachment.

#598501

Nigel
Supporter

Sprachen: Englisch (English ) Spanisch (Español )

Zeitzone: Europe/London (GMT+01:00)

Screen Shot 2017-12-13 at 13.11.56.png

Hi Marco

From what you describe it sounds like you need the relationship with the filters to be OR rather than AND.

When you set start and end dates in the filters of 1 April and 30 April you want to include all posts with start date >= 1 April and end date <= 30 April, but also any post with end date <= 30 April (even if their start date is < 1 April) and any post with start date >= 1 April (even if their end date is > 30 April).

In the same Query Filter section, edit the Fields relationship to be OR not AND.

#598691

That did the trick! Great man. I created my own first really cool search for woocommerce products!!!! This is an awesome feeling.

Cheers

Marco

#599830

Hi,

I am seeing some problems with our setting now. When you select 1 jan 2018 till 31 dec 2018 it will not show any post. What can I do to prevent this?

Cheers

Dieses Ticket ist jetzt geschlossen. Wenn Sie ein Toolset Kunde sind und Hilfe benötigen, eröffnen Sie bitte ein neues Support-Ticket.