I have tested with an ACF Date Picker for the event date, it doesnāt work: either the syntax above is wrong or dates canāt be compared (different formats) or a feature is not implemented orā¦
This creates a timestamp for the end of today, and compares if the field value is more than that. Could you see if that works?
@avanti - I like how your suggested code looks. It should ideally work as simple as that, except maybe using an attribute after, to differentiate it from comparing the literal text, like value=today.
OK, Iāve made a note to improve date comparisons, and will return to this discussion topic to write an update.
Thanks for the detailed suggestions.
The many examples in CCS docs are key helpers for non developper, they were precious starting points to me, iām glad that L&L follows the same way.
I also discover these features in your post, :
{Date format=timestamp} with the curly brackets, to fill a value
ā¦and the implementation of Set/Get, with {Getā¦} to fill a value too
Thatās great.
Unfortunately i wasnāt able to make these work in a loop.
Hereās my code, with an ACF Date Picker on Posts to set the Event date:
I checked twice, despite one of the post has a future date set in the ACF, the second condition in the loop is not true and doesnāt output āUpcoming Eventā for this post as it should.
Maybe dates formats are not similar and comparable, between ACF and {Date format=timestamp}, iām not sure.
Right, itās about different dates formats. Currently, the more_than operator only knows how to compare numbers - which means given values need to be formatted as timestamps.
Another thing which is different from CCS is the use of attribute acf_date instead just field. That lets the plugin know to use ACF to get the value, and process it as a date; itās more reliable than using the raw field value.
Iām still trying to decide a new syntax, how to express a condition like this in a shorter way.
Glad youāre enjoying the newly improved details of Loops and Logic.
Good point about the usefulness of examples - I imagine many will accumulate here in the forums, but it would be nice to have a community library of code snippets. Iāve made a note to think about how to build it.
The code you propose works alright, thanks a lot for taking the time to test and share.
In this example i discover the usage of check, looks like a flexible function.
Thank you both very much for taking the time to explore and explain these functions. Thereās quite a lot to take in, but I will take a look at testing these myself later on, as I have some other pressing work to be getting on with right now.
I will also report back and let you know how I got on.