Skip to content

Instantly share code, notes, and snippets.

@cliffordp
Last active August 23, 2018 05:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cliffordp/6a66affeab8ac57d7ceea942f8c417ff to your computer and use it in GitHub Desktop.
Save cliffordp/6a66affeab8ac57d7ceea942f8c417ff to your computer and use it in GitHub Desktop.
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' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment