Last active
December 24, 2015 12:19
-
-
Save jazbek/6797419 to your computer and use it in GitHub Desktop.
Fix show events in main blog loop option with static front page
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_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