Created
January 15, 2014 00:00
-
-
Save jazbek/8428371 to your computer and use it in GitHub Desktop.
Fix broken sliders in some themes with The Events Calendar 3.2+
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'tribe_events_query_posts_fields', 'tribe_fix_multi_posttype_fields', 10, 2 ); | |
function tribe_fix_multi_posttype_fields( $fields, $query ) { | |
global $wpdb; | |
if ( $query->tribe_is_multi_posttype ) { | |
foreach ( $fields as $key => $field ) { | |
$fields[$key] = str_replace( $wpdb->postmeta, 'tribe_event_postmeta', $field ); | |
} | |
} | |
return $fields; | |
} | |
add_filter( 'tribe_events_query_posts_joins', 'tribe_fix_multi_posttype_joins' ); | |
function tribe_fix_multi_posttype_joins( $joins ) { | |
global $wpdb; | |
if ( array_key_exists('event_start_date', $joins ) ) { | |
$joins['event_start_date'] = str_replace( "LEFT JOIN {$wpdb->postmeta} on", "LEFT JOIN {$wpdb->postmeta} as tribe_event_postmeta on", $joins['event_start_date'] ); | |
$joins['event_start_date'] = str_replace( "{$wpdb->postmeta}.post_id", "tribe_event_postmeta.post_id", $joins['event_start_date'] ); | |
$joins['event_start_date'] = str_replace( "{$wpdb->postmeta}.meta_key =", "tribe_event_postmeta.meta_key =", $joins['event_start_date'] ); | |
} | |
return $joins; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment