Skip Navigation

[Resolved] Display Condition to show content ‘X’ days before a date field

This thread is resolved. Here is a description of the problem and solution.

Problem:
Display Condition to show content 'X' days before a date field

Solution:
You can use date functions that will help you to compare the custom date field with [wpv-conditional] shortcode.

You can find the proposed solution, in this case, with the following reply:
=> https://toolset.com/forums/topic/display-condition-to-show-content-x-days-before-a-date-field/#post-1120454

Relevant Documentation:
=> https://toolset.com/documentation/user-guides/date-filters/
=> https://toolset.com/documentation/beyond-the-basics/conditionally-show-content/#strike-through-event-dates-that-have-passed

This support ticket is created 6 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.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 2 replies, has 2 voices.

Last updated by Lee 6 years, 1 month ago.

Assisted by: Minesh.

Author
Posts
#1119824

Lee

Hi,

I am trying to display content using a conditional output based on a Toolset date field.

When an event is more than 30 days away the user has an option to pay a deposit, then pay in full closer to the event.
If the event is in 30 days or less I need to hide any content relating to the deposit option.

Something along the lines of below. Essentially it's just the bit between the ** that I need...

[wpv-conditional if="( $(wpcf-event-date) ** > 30 days away ** )"]DEPOSIT AVAILABLE[/wpv-conditional]
[wpv-conditional if="( $(wpcf-event-date) ** < 30 days away ** )"]DEPOSIT NOT AVAILABLE[/wpv-conditional]

Help much appreciated!

Thanks
James

#1120454

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - what if you try to use the following shortcodes:

You can use date functions that will help you to compare the custom date field.

If event after 30 days:

[wpv-conditional if="( $(wpcf-event-date) gte FUTURE_DAY(30) )" debug="true"]
Yes - this is after 30 days
[/wpv-conditional]

If even before 30 days:

[wpv-conditional if="( $(wpcf-event-date) lte FUTURE_DAY(30) )" debug="true"]
Yes - this is after 30 days
[/wpv-conditional]

More info:
=> https://toolset.com/documentation/user-guides/date-filters/
=> https://toolset.com/documentation/beyond-the-basics/conditionally-show-content/#strike-through-event-dates-that-have-passed

#1123843

Lee

My issue is resolved now. Thank you!