Skip Navigation

[Resolved] View "Date condition" not functioning as expected (after today)

This support ticket is created 5 years, 3 months ago. 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.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 3 replies, has 2 voices.

Last updated by Christian Cox 5 years, 3 months ago.

Assisted by: Christian Cox.

Author
Posts
#1346219
Screen Shot 2019-09-23 at 8.55.26 AM.jpg

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.

#1346715
Screen Shot 2019-09-23 at 6.15.42 PM.png

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/

#1349095

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.

#1349271

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