Skip to content

Instantly share code, notes, and snippets.

@jazbek
Last active December 24, 2015 12:19
Show Gist options
  • Select an option

  • Save jazbek/6797419 to your computer and use it in GitHub Desktop.

Select an option

Save jazbek/6797419 to your computer and use it in GitHub Desktop.
Fix show events in main blog loop option with static front page
<?php
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