Skip to content

Instantly share code, notes, and snippets.

@andrasguseo
Created October 4, 2018 11:17
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 andrasguseo/9a0b6c709820e6cd1e20695fc35def31 to your computer and use it in GitHub Desktop.
Save andrasguseo/9a0b6c709820e6cd1e20695fc35def31 to your computer and use it in GitHub Desktop.
EC Pro - hide recurrences in category view
<?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