Last active
August 23, 2018 05:03
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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