Advertisement
kelly-tribe

3.1: Fix for include events in main blog loop

Oct 2nd, 2013
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.69 KB | None | 0 0
  1. add_action( 'init', 'tribe_fix_homepage', 11, 1 );
  2. function tribe_fix_homepage() {
  3.     remove_action( 'parse_request', array( 'TribeEventsQuery', 'parse_request' ), 50 );
  4.     add_action( 'parse_query', 'tribe_fix_homepage_query' );
  5. }
  6.  
  7. function tribe_fix_homepage_query( $query ) {
  8.     if ( $query->is_main_query() && is_home() ) {
  9.         // check option for including events in the main wordpress loop, if true, add events post type
  10.         if ( tribe_get_option( 'showEventsInMainLoop', false ) ) {
  11.             $query->query_vars['post_type'] = isset( $query->query_vars['post_type'] ) ? (array) $query->query_vars['post_type'] : array( 'post' );
  12.             $query->query_vars['post_type'][] = TribeEvents::POSTTYPE;
  13.         }
  14.     }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement