Hello.
I've a view which is outputting a post type called Race.
Right now, it is outputting the title and some custom fields; a select box (race-type), a text line (race-target) and a date and time (race-date).
These all output fine.
If a change the query to filter on the text line, that also works.
I.e. I've 2 entries in there right now, one is "road" and the other is "trail". If I use the query filter and put
"Select items with field:
Race Type is a string equal to trail"
I get the race entry set as trail. If I swap it to road, I get the road one. This means that the view is seeing both rows and able to see the custom fields.
What I want to do is only show races in the future but it's not working. My two races have dates as 06 December 2020 10:00 and 10 January 2021 09:30
I've added a query filter like this:
"Select items with field:
Race Date is a DATETIME greater than NOW()"
but it only returns the single race with the date set as 10 January 2021 09:30.
It doesn't seem to help if I used TODAY() or DATE as well.
There is another query filter applying to this:
"Select posts in Any relationship that are related to the Post where this View is shown." as this view is being displayed in the custom template of a Macrocycle post type which is related to the races with a many to many relationship. Both of these races are linked to this Macrocycle.
Any clues on how to debug or what's going on?
Hi, if you're using a Types date/time field, that information is stored in the database in a format called a Unix timestamp. This is basically an integer representing the amount of time since the beginning of date January 1 1970: https://www.unixtimestamp.com/
The correct comparison type here would be "as a number" or "as an UNSIGNED", instead of DATETIME. Greater than NOW() should be okay. Please make this change and let me know if the results are what you would expect. If not, try temporarily deactivating all other plugins and switching to a default theme like Twenty Twenty to eliminate any possible conflicts. If you're still seeing unexpected results, I will take a closer look.
Great! That was it.
"Select items with field:
Race Date is a number greater than NOW()" returns what I expect.