Okay, so I think I’ve found the issue. The query for past events is a mess.
$wp_the_query currently shows
SELECT SQL_CALC_FOUND_ROWS DISTINCT
wp_posts.*,
wp_postmeta.meta_value as EventStartDate,
tribe_event_duration.meta_value as EventDuration,
DATE_ADD(CAST(wp_postmeta.meta_value AS DATETIME),
INTERVAL tribe_event_duration.meta_value SECOND) as EventEndDate FROM wp_posts
LEFT JOIN wp_postmeta as tribe_event_duration
ON ( wp_posts.ID = tribe_event_duration.post_id AND
tribe_event_duration.meta_key = '_EventDuration' )
WHERE 1=1 AND
wp_posts.post_type = 'tribe_events' AND
(wp_posts.post_status = 'publish') AND
DATE_ADD(CAST(wp_postmeta.meta_value AS DATETIME), INTERVAL tribe_event_duration.meta_value SECOND) < '2013-07-09 13:31:22'
ORDER BY wp_posts.post_date DESC LIMIT 0, 5
There is no postmeta row with the key ‘_EventDuration’ There are only start and end date keys. The query should read:
SELECT SQL_CALC_FOUND_ROWS DISTINCT
wp_posts.*,
tribe_event_start.meta_value as EventStartDate,
tribe_event_end.meta_value as EventEndDate,
TIMESTAMPDIFF(SECOND,tribe_event_start.meta_value,tribe_event_end.meta_value) as EventDuration
FROM wp_posts
LEFT JOIN wp_postmeta as tribe_event_start
ON ( wp_posts.ID = tribe_event_start.post_id AND
tribe_event_start.meta_key = '_EventStartDate' )
LEFT JOIN wp_postmeta as tribe_event_end
ON ( wp_posts.ID = tribe_event_end.post_id AND
tribe_event_end.meta_key = '_EventEndDate' )
WHERE 1=1 AND
wp_posts.post_type = 'tribe_events' AND
(wp_posts.post_status = 'publish') AN
tribe_event_end.meta_value < '2013-07-09 13:31:22'
ORDER BY wp_posts.post_date DESC LIMIT 0, 5
When I run this query against my db it returns the past events. Now that I know the proper query I just need to figure out where in the PHP code this query is sent.
Any help would be appreciated.