Created
June 16, 2015 20:14
-
-
Save tomfinitely/af9fbfc136ce964ada5f to your computer and use it in GitHub Desktop.
FIX FOR STATIC FRONT PAGE BEING OVERRIDDEN WHEN INCLUDING EVENTS IN MAIN BLOG LOOP
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
add_action( 'init', 'tribe_fix_homepage', 11, 1 ); | |
function tribe_fix_homepage() { | |
remove_action( 'parse_request', array( 'TribeEventsQuery', 'parse_request' ), 50 ); | |
add_action( 'parse_query', 'tribe_fix_homepage_query', 51 ); | |
} | |
function tribe_fix_homepage_query( $query ) { | |
if ( ! $query->is_main_query() ) { | |
$query->is_home = false; | |
} | |
if ( $query->is_main_query() && is_home() ) { | |
// check option for including events in the main wordpress loop, if true, add events post type | |
if ( tribe_get_option( 'showEventsInMainLoop', false ) ) { | |
$query->query_vars['post_type'] = isset( $query->query_vars['post_type'] ) ? (array) $query->query_vars['post_type'] : array( 'post' ); | |
$query->query_vars['post_type'][] = TribeEvents::POSTTYPE; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment