I am trying to: Setup a view to display CPT items that were published at some point today. I trying to do that by creating a view and setting up the Post Date Filter with "equal to" and Day = "CURRENT_ONE". Take a look at the screenshot.
I expected to see: Posts from today
Instead, I got: Posts from THIS DAY of the month from ANY month in the past... for example if today is September 23rd... the view is displaying items from today (good) but also from August 23rd, July 23rd, etc... (bad).
I just want items from TODAY... I thought that's what CURRENT_ONE would do.
Hi, the "equal to" operator for publish date isn't usually very helpful unless each post is published at exactly the same time of day. Posts are usually published around the clock, so the "between" operator is usually more effective. I would set the filter to show published dates between the day of the year : CURRENT_ONE and FUTURE_ONE ( 1 ). Then add another date condition that specifies the Year as CURRENT_ONE. See my configurations in the screenshot. This setup should show you posts published any time today from midnight last night until NOW. Posts scheduled to be published later tonight will not appear in the results yet.
We have more information about post date filters available here: https://toolset.com/documentation/user-guides/filtering-views-query-by-date/
Hi Christian,
That seems to work! Thank you! Related question... if I wanted to show results from 30 days ago until today I understand now how to do that (using the technique you shared)... but in that scenario what happens when the year changes... example on January 15th? I don't think it would pull any results from December (because of the year variable).
Do you have any insight into this?
Thanks.
Filters like "n" days ago aren't easily achieved in wp-admin. You can use custom code to specify a number of days in a filter. See this other ticket for an example and explanation: https://toolset.com/forums/topic/best-way-to-display-posts-from-last-30-days