Instantly share code, notes, and snippets.

Embed
What would you like to do?
Events Calendar PRO: Set the "Show only the first instance of each recurring event (only affects list-style views)" option only on certain page/post IDs.
<?php
/**
* Events Calendar PRO: Set the "Show only the first instance of each recurring event (only affects list-style views)"
* option only on certain page/post IDs.
*
* Useful if you are embedding a List View within a specific page, such as via shortcode or widget, and you want to hide
* the recurrences ONLY in this context.
* !!! CHANGE TO YOUR OWN POST IDs WITHIN THIS SNIPPET'S CODE !!!
*
* @link https://gist.github.com/cliffordp/69d00ce54929393410e27a319762d241 This snippet.
* @link https://gist.github.com/andrasguseo/9a0b6c709820e6cd1e20695fc35def31 A very similar snippet for Event Categories.
*/
function cliff_hide_recurrences_on_specific_pages( $hide ) {
// If already hiding, just go with it.
if ( $hide ) {
return $hide;
}
global $post;
// @TODO: Set all your Post/Page/Custom Post Type Post IDs here - where recurrences should be hidden
$post_ids_to_apply_to = [
414, // http://example.com/evenemang/
424, // http://example.com/workshops/
];
if (
! empty( $post->ID )
&& in_array( $post->ID, $post_ids_to_apply_to )
) {
return true;
} else {
return $hide;
}
}
add_filter( 'tribe_events_pro_should_hide_recurrence', 'cliff_hide_recurrences_on_specific_pages' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment