Created
May 9, 2017 06:36
-
-
Save GeoffEW/27b1228b4dd425294a050df0fb63010e to your computer and use it in GitHub Desktop.
Show all markers on Map view
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 | |
function show_all_markers( $data ) { | |
if ( ! isset( $data['markers'] ) ) return $data; | |
$cached_markers = get_transient( 'all_geo_markers_store' ); | |
if ( $cached_markers ) { | |
$data['markers'] = $cached_markers; | |
return $data; | |
} | |
$geo_loc = Tribe__Events__Pro__Geo_Loc::instance(); | |
$events = tribe_get_events( array( | |
'posts_per_page' => -1, | |
'eventDisplay' => 'map' | |
) ); | |
$markers = $geo_loc->generate_markers( $events ); | |
set_transient( 'all_geo_markers_store', $markers, DAY_IN_SECONDS ); | |
$data['markers'] = $markers; | |
return $data; | |
} | |
add_filter( 'tribe_events_ajax_response', 'show_all_markers' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment