Skip Navigation

[Closed] Conditional by post date eq today

This support ticket is created 4 years, 9 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 3 replies, has 2 voices.

Last updated by Luo Yang 4 years, 9 months ago.

Assisted by: Luo Yang.

Author
Posts
#1574181

I need to set a conditional like this:
[wpv-conditional if="( '[wpv-post-date]' eq '[today]' )"]

How can i set "today" correctly?
Thanks.

#1575199

Hello,

You don't need to create the custom shortcode, you can use the WordPress built-in function date_i18n():
https://developer.wordpress.org/reference/functions/date_i18n/

For example:
1) Dashboard-> Toolset-> Settings-> Front-end Content
in section "Functions inside conditional evaluations", add the function name: date_i18n

2) Setup the [wpv-conditional] shortcode, like this:

[wpv-conditional if=" ('[wpv-post-date format="Y-m-d"]' eq date_i18n('Y-m-d') )"] 
Here display something ... 
[/wpv-conditional]

More help:
Using custom functions in conditions
https://toolset.com/documentation/user-guides/views/conditional-html-output-in-views/using-custom-functions-in-conditions/

#1579193
Screen Shot 2020-04-08 at 22.25.57.png
Screen Shot 2020-04-08 at 22.23.47.png

Thanks Luo!

When i access toolset setting page to add date_i18n, return: There has been a critical error on your website. Please check your site admin email inbox for instructions (attached image).

I have all plugins and core updated.
Any ideia?

#1579213

I have tried it in my localhost, it works fine.

Please check these in your website:
1) It seems there are some PHP errors in your website, please share the PHP debug logs:
https://toolset.com/documentation/programmer-reference/debugging-sites-built-with-toolset/

2) In case it is a compatibility problem, please deactivate all other plugins, and switch to wordpress default theme 2020, deactivate all custom PHP/JS code snippets, and test again

3) If the problem still persists, please provide database dump file(ZIP file) of your website, also point out the problem page URL, I need to test and debug it in my localhost, thanks
https://toolset.com/faq/provide-supporters-copy-site/

The topic ‘[Closed] Conditional by post date eq today’ is closed to new replies.