Home › Forums › Calendar Products › Events Calendar PRO › How to get all events to show in Map View without all events being listed below.
- This topic has 5 replies, 3 voices, and was last updated 8 years, 8 months ago by Support Droid.
-
AuthorPosts
-
July 24, 2015 at 6:56 am #989841JosiahParticipant
I using the Map View in Events Calendar Pro and I have ran into an issue where the only events that show on the map are the events that are listed below. So if I have 100 events, but have to view limited to 10 events per page, I only will see 10 events on the map. I would to be able to have all 100 events on the map even if only 10 of the events are displayed below the map.
Is this something I can do?
Thank You,
JosiahJuly 24, 2015 at 2:44 pm #990148NicoMemberHowdy Josiah,
Thanks for reaching out to us! Nice question indeed.
One thing that can be done on that end is to alter the query if you are on map view, but both the map and the list get the events from the same ajax call. So not sure if this will be useful for your particular case:
add_action( 'tribe_events_pre_get_posts', 'unlimit_map_view' );
function unlimit_map_view( $query ) {if ( defined( 'DOING_AJAX' ) && DOING_AJAX && $query->get('eventDisplay') == 'map' ) {
$query->set('posts_per_page', '-1');
}return $query;
}
Maybe you can alter the display of the events in the list, hiding them or just some of them. Further customization will probably require to refactor a bit how this actually works.
Do you think you can find a way around your need with this snippet?
Best,
NicoJuly 27, 2015 at 11:05 am #990621JosiahParticipantHi Nico,
Thanks for the snippet of code. Obviously, the issue is it will unlimit both the map and list portion of the page. How could I just unlimit the map portion, but still limit the list portion to like 10 events.
Any assistance on the script would be great.
Thank You,
JosiahJuly 27, 2015 at 3:30 pm #990759NicoMemberHi Josiah,
Thanks for the follow-up!
I’m afraid by-passing the ajax call for the map or the post list will require some custom code (not just a snippet) and that would be out of our support scope. But I’ll ping the dev team about this tomorrow, maybe they can come up with a smarter approach on this.
Thanks for your patience on this, hope there’s an easy fix for this,
Best,
NicoJuly 29, 2015 at 8:34 am #991443NicoMemberHey Josiah,
Thanks for your patience on this. Hopefully Barry -a superb coder from our team- came up with a snippet that enables this!
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' );
Please bear in mind there’s some caching going on there, so it doesn’t run the query every time the view is loaded. You can comment that out while testing to see if this works for you.
Let me know how this goes,
Best,
NicoAugust 13, 2015 at 7:05 am #995725Support DroidKeymasterThis topic has not been active for quite some time and will now be closed.
If you still need assistance please simply open a new topic (linking to this one if necessary)
and one of the team will be only too happy to help. -
AuthorPosts
- The topic ‘How to get all events to show in Map View without all events being listed below.’ is closed to new replies.