[Gelöst] Using META Query in Bricks to filter by date.
This support ticket is created vor 7 Monaten, 2 Wochen. 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.
I am experimenting with the linked site as a rebuild using Bricks. I have the option of using the original views or, implementing the loop natively in Bricks.
To filter to just the next concert in the original view I vae it set up to query against an event date/time field where if the event is older than TODAY it wount show and the next concert in the listings is displayed, till all are complete and then there is just a message wait for the next seasons listings.
I have been able to build out the same loop in Bricks where just one item is listed but am having issues figuring out how to filter on the date time field. I have looked at the following Bricks forum in how somebody is doing this with ACF, which is a bit more integrated than Toolset.
versteckter Link
Here is a screen shot of the Meta Query filter setup where {ts_event-date-time} is the custom field. And also how it is configured in Toolset. I note that in Toolset the format/type is string.
From a brief look over the Bricks forum there needs to be parity in how the date-time formatter is set. Do we now what TODAY is in code format?
Toolset dates fields are stored as timestamps (the number of seconds since 1 Jan 1970), and any date comparison to filter posts by custom date fields must also be as timestamps, to compare like-with-like. Hence in the View filter, TODAY refers to the timestamp for today (at 00:00).
In which case you are actually comparing numbers (integers).
If you are using something else to generate the query (in this case, Bricks), then the meta value you should be comparing against should be a timestamp (the PHP function time() would generate the current timestamp, for example).
If I am reading you correctly, I need to run a php function that queries time() to return an interger for the current time and then compare this to the value in my event-date-time field?
From your Bricks screenshot, the meta value comes from "date(TODAY)", and I note a lightning symbol, which I guess means the value can be dynamic, perhaps from a PHP statement, or a custom function.
I was suggesting you replace date(TODAY) with such a statement or function, if it is the case that Bricks allows you to put a function or statement there.
And, yes, whatever you use, it needs to return a timestamp.
Thanks Nigel. I will experiment and see how I get on. If all fails I can fallback on the Views I have already built for all this but I have a number of concerms.
1. I see in the DOM that all Toolset Views are preceded by a wrapping div containing a lot of data attributes which is avoided if using a purely Bricks approach.
2. I feel like one of the last of the holdouts by still using Toolset. I have to admit that I am looking at alternatives for the future and, for current sites migration tools for something like Met Box. I'd rather stick with Toolset because from what I can see, it offers the most extensive featur set when you include the integratoin with maps.
I would love to see some annoucment from the top (Amir) stating some commitment to the plugin. I am sure there is some new features that could be added, just enough to give it that little boost to put iit back in front of potential customers as a viable option.