Skip to content

Instantly share code, notes, and snippets.

@vicskf
Created March 22, 2017 04:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vicskf/5854eb1f88b8886c39743ca250a4ba99 to your computer and use it in GitHub Desktop.
Save vicskf/5854eb1f88b8886c39743ca250a4ba99 to your computer and use it in GitHub Desktop.
<?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 );
@deblynprado
Copy link

Just for cross-reference, here are the new solution for Redesigned Views of The Events Calendar

Function - https://gist.github.com/lelandf/3d5e1453de9221c8e4e4293c7787ecbd
Template Override - https://gist.github.com/lelandf/549ec99ea456179dd2256c7613116c41

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