Skip to content

Instantly share code, notes, and snippets.

@keccers
Created December 17, 2013 17:57
Show Gist options
  • Save keccers/8009558 to your computer and use it in GitHub Desktop.
Save keccers/8009558 to your computer and use it in GitHub Desktop.
Horror Query
SELECT DISTINCT wp_posts.ID, wp_postmeta.meta_value as EventStartDate, IF(tribe_event_duration.meta_value IS NULL, tribe_event_end_date.meta_value, DATE_ADD(CAST(wp_postmeta.meta_value AS DATETIME), INTERVAL tribe_event_duration.meta_value SECOND)) as EventEndDate, tribe_event_duration.meta_value as EventDuration FROM wp_posts INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id) AND wp_postmeta.meta_key = '_EventStartDate' LEFT JOIN wp_postmeta as tribe_event_end_date ON ( wp_posts.ID = tribe_event_end_date.post_id AND tribe_event_end_date.meta_key = '_EventEndDate' ) 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' OR wp_posts.post_status = 'private') AND (wp_postmeta.meta_key = '_EventStartDate' ) AND ((wp_postmeta.meta_value >= '2013-12-01' AND wp_postmeta.meta_value <= '2013-12-31') OR (IF(tribe_event_duration.meta_value IS NULL, tribe_event_end_date.meta_value, DATE_ADD(CAST(wp_postmeta.meta_value AS DATETIME), INTERVAL tribe_event_duration.meta_value SECOND)) >= '2013-12-01' AND wp_postmeta.meta_value <= '2013-12-31' ) OR (wp_postmeta.meta_value < '2013-12-01' AND IF(tribe_event_duration.meta_value IS NULL, tribe_event_end_date.meta_value, DATE_ADD(CAST(wp_postmeta.meta_value AS DATETIME), INTERVAL tribe_event_duration.meta_value SECOND)) >= '2013-12-31' )) GROUP BY ID ORDER BY DATE(wp_postmeta.meta_value) ASC, TIME(wp_postmeta.meta_value) ASC
Call from: require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/artsbrookfield/tribe-events/default-template.php'), tribe_get_view, include('/themes/artsbrookfield/tribe-events/list.php'), tribe_get_template_part, include('/themes/artsbrookfield/tribe-events/list/content.php'), tribe_get_template_part, include('/themes/artsbrookfield/tribe-events/list/loop.php'), dynamic_sidebar, call_user_func_array, WP_Widget->display_callback, TribeEventsMiniCalendarWidget->widget, TribeEventsMiniCalendar->do_calendar, tribe_get_view, include('/themes/artsbrookfield/tribe-events/widgets/mini-calendar-widget.php'), tribe_show_month, tribe_get_view, do_action('tribe_events_before_view'), call_user_func_array, Tribe_Events_Month_Template->setup_view, Tribe_Events_Month_Template::get_daily_counts, TribeEventsQuery::getEventCounts, WP_Query->query, WP_Query->get_posts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment