Skip to content

Instantly share code, notes, and snippets.

@vicskf
Created September 27, 2017 16:11
Show Gist options
  • Save vicskf/1b0cfd63909d129e59c5ea4280bdeb3d to your computer and use it in GitHub Desktop.
Save vicskf/1b0cfd63909d129e59c5ea4280bdeb3d to your computer and use it in GitHub Desktop.
The Events Calendar > Month View > Shows the event for the first day and remove it from the rest in a multi-day event
<?php
/*
* Shows the event for the first day and remove it from the rest in a multi-day event.
* Limited to month view only
*
* Author: Barry Hughes
*/
function reduce_month_view_single_events( $events ) {
static $rendered_ids = array();
foreach ( $events['events']->posts as $index => $post ) {
if ( in_array( $post->ID, $rendered_ids ) ) {
unset( $events['events']->posts[ $index ] );
}
else {
$rendered_ids[] = $post->ID;
}
}
remove_filter( 'tribe_events_get_current_month_day', 'reduce_month_view_single_events' );
return $events;
}
function setup_month_view_single_event_filter( $slug, $name ) {
if ( $name === 'day' ) {
add_filter( 'tribe_events_get_current_month_day', 'reduce_month_view_single_events' );
}
}
add_action( 'tribe_pre_get_template_part_month/single', 'setup_month_view_single_event_filter', 10, 2 );
@Clark-Ros
Copy link

Hi

This seems to be outdated. Specifically this action tribe_pre_get_template_part_month/single. Would it be possible to get this working on the latest version 5.1.2?

many thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment