Skip Navigation

[Resolved] conditional statement with dates

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

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Tagged: 

This topic contains 2 replies, has 2 voices.

Last updated by horngO 5 years, 1 month ago.

Author
Posts
#1345263

How would I go about in writing a conditional statement that checks if current post's post date is from this year?

#1345285

You mean a Conditional HTML or a query filter in a view?

In any case you would have to compare as NUMBERs, since Toolset saves timestamps, you cannot compare by a date but only by another timestamp, which are numbers.

Conditional HTML is explained here: https://toolset.com/documentation/user-guides/conditional-html-output-in-views/, https://toolset.com/documentation/user-guides/conditional-html-output-in-views/checking-types-fields-and-custom-fields/#using-fields-together-with-date-filters
You can use these constants as well:
https://toolset.com/documentation/user-guides/date-filters/

This should help to craft such conditions, however please do not hesitate to ask me if something is not clear.

#1350941

I am referring to conditional html. What I want to do is basing on the the post date if it's within the past three months, it will display a message.

I have looked through the docs and came up with the following.

[wpv-conditional if="( '[wpv-post-date]' gt 'PAST_MONTH(3)' )"]posted within the past three months[/wpv-conditional]