Passer la navigation

[En attente du retour de l'utilisateur] Filter by specific dates

This support ticket is created Il y a 1 week, 2 days. 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.

Ce sujet contient 1 reply, a 1 voix.

Dernière mise à jour par Christopher Amirian Il y a 1 week, 1 day.

Assisté par: Christopher Amirian.

Auteur
Publications
#2861239

Tell us what you are trying to do?
I have some events happening on specific dates, (set by an event start and end datetime). I want my filter to have buttons for specific days, so that the user can click (for example) 5 Jun to show all events on 5 June, or 6 June or whichever of my limited 14 days of events. I don't want to use a datepicker. How do I construct the query (using the legacy and classic views) to limit the exact date?

I imagine it would use a custom url_parameter? So something like

`<button>[wpv-control-postmeta field="wpcf-event_start_datetime" type="textfield" url_param="wpv-wpcf-event_start_datetime&event_start_datetime=some-timestamp"]</button>`

What is the link to your site?
lien caché

#2861347

Christopher Amirian
Supporter

Les langues: Anglais (English )

Hello and welcome to Toolset support.

Unfortunately, it is not possible with the approach you mentioned.

The [wpv-control-postmeta] shortcode renders a form input that Views manages internally — you can't inject extra URL parameters into it by appending them to the url_param attribute. Also, a single datetime field can't be matched with a simple equality check for "all events on a given day," because Toolset stores custom date/datetime fields as Unix timestamps. Searching for an exact timestamp would only match that precise second, not the whole day.

This will need an extensive custom development, which is outside of our support scope. I can give a framework to you but you will need to do the implementation ot find a developer to do that for you.

Use a BETWEEN filter using two timestamps — midnight at the start of the day and 23:59:59 at the end — combined with hidden inputs that your buttons populate via JavaScript.

1. Set up the View Query Filter
2. Build the filter section with hidden inputs and day buttons
3. Use jQuery to wire the buttons to the hidden inputs
4. Calculate your 14 Unix timestamps (for each day)

Even after implementing this, it will work only on page reload mode, and for Ajax mode things got more complicated.

Thanks.