Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Let's inspect the parameters of any event queries
- add_action( 'tribe_events_pre_get_posts', 'tribe_query_include_child_cats' );
- /**
- * Modifies the taxonomy part of an event query and ensures child categories are included.
- *
- * @param $query
- * @return mixed
- */
- function tribe_query_include_child_cats( $query ) {
- // If the tax_query is not specified do not interfere
- $tax_query = $query->get( 'tax_query' );
- if ( ! is_array( $tax_query ) ) return $query;
- // Look for include_children flags and set to true
- foreach ( $tax_query as &$component ) {
- if ( is_array( $component ) && isset( $component['include_children'] ) )
- $component['include_children'] = true;
- }
- // Update the query
- $query->set( 'tax_query', $tax_query );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement