Skip Navigation

[Resolved] Conditional Dates

This support ticket is created 5 years, 5 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

Tagged: 

This topic contains 4 replies, has 2 voices.

Last updated by Nigel 5 years, 5 months ago.

Assisted by: Nigel.

Author
Posts
#1311901

How do I get this statement working so that if the post date is before today's date, it shows one thing. If it is after todays date, it shows another? I tried this below but it doesn't work. And yes, I did add a shortcode for [datetime] to toolset settings. It is simply this: return date(get_option('date_format'));

[wpv-conditional if="( '[types field='[wpv-post-date]' ][/types]' gt '[datetoday]' )"] Show this [/wpv-conditional]
[wpv-conditional if="( '[types field='[wpv-post-date]' ][/types]' lt '[datetoday]' )"] Show this instead [/wpv-conditional]

#1312019

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Mike

You can use the Views date functions such as TODAY() in the conditions. These generate timestamps, so to compare like with like you need the post date in timestamp format.

So this is the kind of thing you need:

[wpv-conditional if="( '[wpv-post-date format='U']' lt 'TODAY()' )"]
<p>Already published!</p>
[/wpv-conditional]
[wpv-conditional if="( '[wpv-post-date format='U']' gt 'TODAY()' )"]
<p>Not yet published!</p>
[/wpv-conditional]

See https://toolset.com/documentation/user-guides/conditional-html-output-in-views/ about setting up conditions, and https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-date for details of outputting the post date in different formats.

#1312385

That worked, thanks much!

#1313421

How do I do it so that if the field wpcf-note-date has not arrived yet (it is a custom calendar field), don't show the message yet? Only show it after that date.

#1314407

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Mike,

looks like you opened a new post with Christian to ask this over the weekend, but let me know if you are still stuck.