Skip Navigation

[Resolved] frontend date filters

This support ticket is created 5 years, 10 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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 5 replies, has 2 voices.

Last updated by Shane 5 years, 10 months ago.

Assisted by: Shane.

Author
Posts
#1182315

Hi
I need to create some date filters on the frontend for events. I have a start date field (timestamp) - evcal_srow and and end date field - evcal_erow.

I can create two date pickers for the start and end and these work. But my problem is that I should have a default query filter like all events from now. But that interferes with the query filters the date pickers set.

Basically I would need to check for a range of dates: datepicker 1: starting date of search, datepicker 2: ending date of search. But I have two dates for every event so the filter should show all the events that fall between the date range set by the two date pickers of the frontend filters.

And I also should make some a button for events of current week, events of current month, all events from now on.

#1182332

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Jozsef,

Thank you for contacting our support forum.

I see your issue with this. However its not possible to have this. What you can do is to add a year field to your posts.

This way you can set a static filter to filter for 2019 posts only. From there you can only filter for 2019 posts.

Please let me know what you think of this.

Thanks,
Shane

#1182334

Sorry, I just updated my questions exactly when you wrote your answere. Can you have look now?

#1182348

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Jozsef,

Thanks for bringing my attention to the update.

In response to the update, the datepicker can only have a between for a single picker.

So what you will end up having in your scenario is 4 datepickers, 2 for start date and 2 for end date.

This way you can do a filter for events where start date is between x and y and end date between y and z.

#1182360
Untitled-2.png
Untitled-1.png

I don't want to search separately for start and end date. Just to find events between 2 given dates. I solved it like this:
hidden link. I uploaded two screenshots. I set the default value of the first URL parameter to TODAY() so this way the grid will show events from today on.

But I guess I cannot create some predefined date range buttons now: events of current week, events of current month, all events from now on. Because I cannot create other query filters with my two date fields. Or is there a way? I thought to create links with given URL parameters but how can I pass a date function like THIS_MONTH() in a URL parameter?

#1182378

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Jozsef,

Yes this method will work really well for just having 2 filters.

I see what you mean with this. Since the date is stored as number or EPOCH time stamp then you wouldn't be able to filter for just a month. It has to be filtered for the entire date.

So it wouldn't be possible because of how the date is being stored.

Thanks,
Shane