Mmm… not with the shortcode, but if you’re using it in a template file then its possible.
You would just query for X number of upcoming events (via eo_get_events()
, extract their venue’s ID (via eo_get_venue( $event_id )
) and then display the venues map with eo_get_venue_map()
, passing the collected venue IDs.
Documentation for these functions can be found here: http://wp-event-organiser.com/documentation/function-reference/
Of course its possible to create a shortcode which does the above if you really need that functionality as a shortcode.
Awesome, thank you!
I’m still playing around with how to specify the map height, but I’ve learned so much more about WordPress by coding up this shortcode than I have from months of using it generally.
Here’s what I came up with using your documentation:
<?php
function eo_upcoming_events_map() {
$events = eo_get_events(array(
'events_start_after'=>'today',
'showpastevents'=>false,//Will be deprecated, but set it to true to play it safe.
));
$venue_array;
if($events):
foreach ($events as $event):
$venue_id = eo_get_venue($event->ID);
$venue_array[] = $venue_id;
endforeach;
endif;
echo eo_get_venue_map($venue_array);
}
add_shortcode('eo_upcoming_events_map','eo_upcoming_events_map');
?>
Sorry for the double-post, but I was able to get the height thing working. I don’t really need the other attributes (e.g. width, venue array, etc) working yet, so I’ll leave it for now – but here’s the code (mostly replicating the proper in-built map shortcode) in case it’s of use to anyone else.
<?php
function eo_upcoming_events_map($args=array()) {
$args_array = array('zoom' => 15, 'scrollwheel'=>true, 'zoomcontrol'=>true, 'rotatecontrol'=>true,
'pancontrol'=>true, 'overviewmapcontrol'=>true, 'streetviewcontrol'=>true,
'maptypecontrol'=>true, 'draggable'=>true,'maptypeid' => 'ROADMAP',
'width' => '100%','height' => '200px','class' => '',
'tooltip'=>false
);
$args = shortcode_atts($args_array , $args );
//Cast zoom as integer
$args['zoom'] = (int) $args['zoom'];
//Escape attributes
$width = esc_attr($args['width']);
$height = esc_attr($args['height']);
$class = esc_attr($args['class']);
//If class is selected use that style, otherwise use specified height and width
if( !empty($class) ){
$class .= " eo-venue-map googlemap";
$style = "";
}else{
$class = "eo-venue-map googlemap";
$style = "style='height:".$height.";width:".$width.";' ";
}
$events = eo_get_events(array(
'events_start_after'=>'today',
'showpastevents'=>false,//Will be deprecated, but set it to true to play it safe.
));
$venue_array;
if($events):
foreach ($events as $event):
$venue_id = eo_get_venue($event->ID);
$venue_array[] = $venue_id;
endforeach;
endif;
echo eo_get_venue_map($venue_array, array('height'=>$height));
}
add_shortcode('eo_upcoming_events_map','eo_upcoming_events_map');
?>
So now I can use [eo_upcoming_events_map height=”600px”] on a page to display only venues with upcoming events.