Skip to content

Instantly share code, notes, and snippets.

@PaulHughes01
Created April 13, 2012 21:42
Show Gist options
  • Save PaulHughes01/2380344 to your computer and use it in GitHub Desktop.
Save PaulHughes01/2380344 to your computer and use it in GitHub Desktop.
Add post-categorized events to the query
<?php
/* Add to the bottom of your functions.php file. */
function query_post_type($query) {
if(is_category() || is_tag() || is_archive() || is_search() || is_home() && empty( $query->query_vars['suppress_filters'] ) ) {
$post_type = get_query_var( 'post_type' );
if ( $post_type )
$post_type = $post_type;
else
$post_type = array( 'post','tribe_events' );
$query->set( 'post_type', $post_type );
if ( is_array( $post_type ) && in_array( 'tribe_events', $post_type ) ) {
$categories = get_categories();
$category_ids = array();
foreach ( $categories as $category ) {
$category_ids[] = $category->cat_ID;
}
$query->set( 'cat', join( ',', $category_ids ) );
}
return $query;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment