Skip Navigation

[Resolved] The Events Calendar / Venue Map on Single Event Template

This support ticket is created 2 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

Author
Posts
#2083545

Hello,

I'm using Toolset to create a single event template for The Events Calendar. However, I'm struggling to get the Venue Location to show.

The Events Calendar plugin stores Venues as a separate post type, and links to the venue post using the field '_EventVenueID'. So I've used this as a basis to get Venue data into the Single Event template - e.g. [wpv-post-field name='_VenueCity' id="[wpv-post-field name='_EventVenueID']

However, I'm struggling to get a map to show with the Venue Location. Using the map block doesn't appear to give any usable options so I'm thinking a shortcode approach is best. I tried something like this for the marker but it doesn't appear to be working - [wpv-map-marker map_id="my-map" marker_id="my-marker" lat="[wpv-post-field name='_VenueLat' id="[wpv-post-field name='_EventVenueID']" lon="[wpv-post-field name='_VenueLng' id="[wpv-post-field name='_EventVenueID']"][/wpv-map-marker] - because I think there are two many levels of nested shortcodes?

Any suggestions on how to get this to work?

Thanks

#2084489

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting us and I'd be happy to assist.

During my tests, I was able to show the venue's map marker on the single event page, using the following steps:

1. I registered a custom shortcode, which first gets the current event's venue ID and then extracts the address items from its custom fields to return a complete formatted address:


add_shortcode('venue_address_custom', 'venue_address_custom_func');
function venue_address_custom_func( ) {

	$current_event = do_shortcode("[wpv-post-id]");
	$current_event_venue = do_shortcode("[wpv-post-field name='_EventVenueID']");

	$venue_address = do_shortcode("[wpv-post-field name='_VenueAddress' id='".$current_event_venue."']");
	$venue_city = do_shortcode("[wpv-post-field name='_VenueCity' id='".$current_event_venue."']");
	$venue_state = do_shortcode("[wpv-post-field name='_VenueState' id='".$current_event_venue."']");
	$venue_province = do_shortcode("[wpv-post-field name='_VenueProvince' id='".$current_event_venue."']");
	$venue_zip = do_shortcode("[wpv-post-field name='_VenueZip' id='".$current_event_venue."']");
	$venue_country = do_shortcode("[wpv-post-field name='_VenueCountry' id='".$current_event_venue."']");

	return $venue_address.' '.$venue_city.' '.$venue_state.' '.$venue_province.' '.$venue_zip.' '.$venue_country;
}

The above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through the active theme's "functions.php" file.

Next, I also added "venue_address_custom" in the "Third-party shortcode arguments" section, at WP Admin -> Toolset -> Settings -> Front-end Content.

2. After that, I was able to show this address on the map, using the "address" attribute and the new shortcode in the map marker shortcode:
( ref: https://toolset.com/documentation/programmer-reference/maps/maps-shortcodes/#wpv-map-marker )


[wpv-map-marker map_id="map-2" marker_id="marker-1" address="[venue_address_custom]"][/wpv-map-marker]

Note: The custom code examples from our forum are shared to get you started in the right direction. You're welcome to adjust them as needed and for more personalized customization assistance, you can consider hiring a professional from our list of recommended contractors:
https://toolset.com/contractors/

regards,
Waqar

#2084647

Thanks Waqar, that's worked perfectly! Much appreciated

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.