Created
September 27, 2017 16:11
-
-
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
This file contains hidden or 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
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