Navigation überspringen

[Gelöst] conditional dates not working

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

Problem:
I am having an issue with my shortcode in Toolset. I'm trying to display specific text based on start and end date fields, but it isn't working as expected.

Solution:
Remove the format attribute from the shortcode, as dates are stored as a UNIX timestamp in Toolset and this format is not required. Also, check the query filter that you used to get the data for the post type. Here's the modified shortcode:

[wpv-conditional if="( $(wpcf-start-date) lte 'TODAY()' ) AND ( $(wpcf-end-date) gte 'TODAY()' )"]
    ON DISPLAY
[/wpv-conditional]
[wpv-conditional if="( $(wpcf-start-date) gte 'TODAY()' )"]
    Coming Soon
[/wpv-conditional]
[wpv-conditional if="( $(wpcf-end-date) lte 'TODAY()' )"]
    Archive
[/wpv-conditional]

This support ticket is created vor 1 Jahr, 10 Monaten. 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.

Dieses Thema enthält 2 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von staceyz vor 1 Jahr, 10 Monaten.

Assistiert von: Christopher Amirian.

Author
Artikel
#2616567

Hi - here is my short code, I cannot figure out why this isn't working. I have an old post here with the same issue, but the site I was working on then is no longer available, so I can't look it up.
https://toolset.com/forums/topic/conditional-date/

I'm trying to show specific text based on start and end date fields.... but this isn't working...

[wpv-conditional if="( $(wpcf-start-date format='U') lte 'TODAY()' ) AND ( $(wpcf-end-date format='U') gte 'TODAY()' )"]ON DISPLAY[/wpv-conditional][wpv-conditional if="( $(wpcf-start-date format='U') gte 'TODAY()' )"]Coming Soon[/wpv-conditional][wpv-conditional if="( $(wpcf-end-date format='U') lte 'TODAY()' )"]Archive[/wpv-conditional]

#2616729

Christopher Amirian
Unterstützer

Sprachen: Englisch (English )

Hi there,

As the dates are stored as a UNIX timestamp in Toolset you do not need to add format in the shortcode. So this should work ok:

[wpv-conditional if="( $(wpcf-start-date) lte 'TODAY()' ) AND ( $(wpcf-end-date) gte 'TODAY()' )"]
    ON DISPLAY
[/wpv-conditional]
[wpv-conditional if="( $(wpcf-start-date) gte 'TODAY()' )"]
    Coming Soon
[/wpv-conditional]
[wpv-conditional if="( $(wpcf-end-date) lte 'TODAY()' )"]
    Archive
[/wpv-conditional]

But the problem might be in the query filter that you used to get the data for the post type.

If the shortcode above is not working, please give the login information of your website by setting the next reply as private (make sure you have a backup of the website).

Then, tell us which view to check and see the result.

Thank you.

#2617019

That worked. Not sure why it wasn't working before (I had added the unix timestamp based on some troubleshooting as the original wasn't working before!)

All good now. Thanks for your support.