Skip Navigation

[Resolved] View Ignoring The Event Start Date Field

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

Problem:
How to filter view by Event Start Date (_EventStartDate) of events Calendar plugi.

Solution:
The thing is that _EventStartDate field stores date as string and Types stores custom date field value as the timestamp.

You can find the proposed solution, in this case, with the following reply:
https://toolset.com/forums/topic/view-ignoring-the-event-start-date-field/#post-1112239

Relevant Documentation:

This support ticket is created 5 years, 7 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
- 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 4 replies, has 2 voices.

Last updated by tylerG 5 years, 7 months ago.

Assisted by: Minesh.

Author
Posts
#1110793

I created a View that displays upcoming events from The Events Calendar plugin. I used the exact same set up as several other sites and pulled in the _EventStartDate field from TEC plugin. The problem is the View doesn't seem to be recognizing the field for ordering or filtering. I even imported a similar View from another site that works great and it doesn't work on this site. I set up a staging site and deactivated all unnecessary plugins and set the theme to 2017 with no luck.

I will pass along a user account to the staging site. To be able to view the site, you'll need to enter username "flywheel" and password "cybersprout". These only allow you to view the site. The account credentials I'll pass through the form.

Thank you!

#1111495

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Could you please share the details which view you are using and to which page you added. Please share problem URL.

Additionally, please share details which view works for you and URL.

I have set the next reply to private which means only you and I have access to it.

#1111632

Here is the test page where the View is not working: hidden link

I'm using the same view loop on other websites where it is working: hidden link

#1112239

Minesh
Supporter

Languages: English (English )

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

The thing is that _EventStartDate field stores date as string and Types stores custom date field value as timestamp.

I've added the following code at "Custom code snippe" section:
=> hidden link

add_filter( 'posts_where' , 'func_posts_where' );
function func_posts_where( $where ) {
 global $wpdb;
global $WP_Views;
 
     if($WP_Views->current_view == 8020){
         
          $where = str_replace("CAST(mt1.meta_value AS SIGNED)","UNIX_TIMESTAMP(mt1.meta_value)",$where);
       
     }
    return $where;
}

I see now - its displaying the correct events now. Could you please confirm.
=> hidden link

#1112308

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.