Events Calendar PRO: Remove Post Tags from the related posts logic and, therefore, only use Event Categories.
<?php
/**
* Events Calendar PRO: Remove Post Tags from the related posts logic and,
* therefore, only use Event Categories.
*
* @see tribe_get_related_posts()
*
* @link https://gist.github.com/cliffordp/6a66affeab8ac57d7ceea942f8c417ff
*
* @param $args
*
* @return array Multidimensional array that gets sent to Tribe__Events__Query::getEvents()
*/
function cliff_remove_tags_from_related_posts_logic( $args ) {
if (
! empty( $args['tax_query'][0]['taxonomy'] )
&& 'post_tag' === $args['tax_query'][0]['taxonomy']
) {
if (
! empty( $args['tax_query']['relation'] )
&& 3 === count( $args['tax_query'] )
) {
unset( $args['tax_query']['relation'] );
}
unset( $args['tax_query'][0] );
}
return $args;
}
add_filter( 'tribe_related_posts_args', 'cliff_remove_tags_from_related_posts_logic' );