Created
March 22, 2017 04:32
-
-
Save vicskf/5854eb1f88b8886c39743ca250a4ba99 to your computer and use it in GitHub Desktop.
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 | |
/* | |
* 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 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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