I've registered the _EventStartDate and _EventEndDate fields from Modern Tribe Events Calendar in Toolset and am able to successfully display them. What I'm wanting to do is conditionally control what is displayed depending on whether the event takes place in a single day, or across multiple days. For example...
If one day: "May 1, 2023"
If multiple days: "May 1 – May 5, 2023"
This is the statement I currently have but it's not displaying the end date:
[date-format date="[wpv-post-field name='_EventStartDate']" format="M j"][wpv-conditional if="( '[date-format date='[wpv-post-field name='_EventStartDate']' format='M j']' ne '[date-format date='[wpv-post-field name='_EventEndDate']' format='M j']' )"]-[date-format date="[wpv-post-field name='_EventEndDate']" format="M j"][/wpv-conditional][date-format date="[wpv-post-field name='_EventEndDate']" format=", Y"]
Any help you can offer is greatly appreciated.
----
What is the link to your site? versteckter Link
Hello,
There isn't such kind of built-in feature within Toolset plugins, I have searched it in Google, and found this thread:
versteckter Link
It seems you can use their function tribe_event_is_multiday() to check if specific event post is a multiple days event.
You might consider to setup custom codes to create a PHP function check the event post, and follow our document to add the function name into Toolset settings:
https://toolset.com/documentation/programmer-reference/views/using-custom-functions-in-conditions/
Thank you, Luo, this is very helpful.
I found the documentation on that function, which I added to Toolset's "Functions inside conditional evaluations" but for some reason it's not working. The documentation (versteckter Link) says the return is boolean but it doesn't seem to be working in my conditional statement.
I've got to be missing something, right? Here's what I have presently:
[date-format date="[wpv-post-field name='_EventStartDate']" format="M j"]
[wpv-conditional if="( tribe_event_is_multiday() eq '1' )"]-[date-format date="[wpv-post-field name='_EventEndDate']" format="M j"][/wpv-conditional]
[date-format date="[wpv-post-field name='_EventEndDate']" format=", Y"]
Thoughts on what I'm missing? Any additional help is greatly appreciated!
Here is a sandbox website:
Login URL:
versteckter Link
1) Dashboard-> Toolset-> Settings-> Front-end Content:
versteckter Link
In section "Functions inside conditional evaluations", add the function name: tribe_event_is_multiday
2) Create a event post, and display the shortcode like this:
[wpv-conditional if="( tribe_event_is_multiday([wpv-post-id]) eq '1' )"]
Multiday Event:
[date-format date="[wpv-post-field name='_EventStartDate']" format="M j"] - [date-format date="[wpv-post-field name='_EventEndDate']" format=", Y"]
[/wpv-conditional]
[wpv-conditional if="( tribe_event_is_multiday([wpv-post-id]) eq '1' )" evaluate="false"]
Single day Event:
[date-format date="[wpv-post-field name='_EventStartDate']" format="M j"]
[/wpv-conditional]
Test it in frontend:
versteckter Link
It works fine. For your reference.
My issue is resolved now. Thank you!