Created
October 4, 2018 11:17
-
-
Save andrasguseo/9a0b6c709820e6cd1e20695fc35def31 to your computer and use it in GitHub Desktop.
EC Pro - hide recurrences in category view
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 | |
/** | |
* Description: Shows only the first instance of a recurring event in category views. | |
* Use solution in the bottom if you want to check for specific categories. | |
* Usage: Copy the snippet in your child theme's functions.php file | |
* Plugins: Events Calendar Pro | |
* | |
* Author: Andras Guseo | |
* Last updated: October 4, 2018 | |
*/ | |
add_filter( 'tribe_events_pro_should_hide_recurrence', 'hide_recurrences_in_category_view' ); | |
function hide_recurrences_in_category_view( $hide ) { | |
if ( tribe_is_event_category() ) { | |
$hide = true; | |
} | |
else { | |
$hide = false; | |
} | |
return $hide; | |
} | |
/** | |
* Alternative solution for checking specific categories | |
* Use either this or the above. Not both! | |
*/ | |
function hide_recurrences_in_category_view( $hide ) { | |
// Category names where recurrences should be hidden. Case sensitive. | |
$categories = [ | |
'Category Name 1', | |
'category name 2', | |
]; | |
foreach ( $categories as $category ) { | |
if ( tribe_meta_event_category_name() == $category ) { | |
$hide = true; | |
break; | |
} | |
else { | |
$hide = false; | |
} | |
} | |
return $hide; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment