Skip to content

Instantly share code, notes, and snippets.

@jesseeproductions
Last active October 14, 2015 20:54
Show Gist options
  • Save jesseeproductions/eface479faf403c89784 to your computer and use it in GitHub Desktop.
Save jesseeproductions/eface479faf403c89784 to your computer and use it in GitHub Desktop.
The Events Calendar - Include Events From Certain Categories on Home Page Main Blog
/*
* The Events Calendar - Exclude Events From Certain Categories on Home Page Main Blog
* add coding to theme's functions.php
* @version 3.12
* change convention and meetup to slug of Event Categories to show add new categories by separating by comma and add slug between apostrophes
*/
add_action( 'pre_get_posts', 'home_exclude_events_category' );
function home_exclude_events_category( $query ) {
if ( $query->is_home() && $query->is_main_query() ) {
$query->set( 'tax_query', array(
array(
'taxonomy' => TribeEvents::TAXONOMY,
'field' => 'slug',
'terms' => array( 'convention', 'meetup' ),
'operator' => 'NOT IN'
)
) );
}
return $query;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment