Skip Navigation

[Waiting for user feedback] Insert map in Divi template for single custom post

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.

This topic contains 1 reply, has 1 voice.

Last updated by Christopher Amirian 2 days, 21 hours ago.

Assisted by: Christopher Amirian.

Author
Posts
#2820893

Tell us what you are trying to do?

I have a Divi-based website that I am adding a directory to. I am using Divi to create the template for my custom post type which has an address field. I want to include a map on the page showing the location.

Is there any documentation that you are following?

I am using this to try to create a shortcode that displays the map with the location: https://toolset.com/documentation/programmer-reference/maps/maps-shortcodes/

Is there a similar example that we can see?

I'm trying to do what this shows but using Divi for the template rather than the block editor: https://toolset.com/lesson-placement/lesson-placements-1622939-1621393/

What is the link to your site?

hidden link

This is the shortcode that I am using so far though I realise it's wrong!

[wpv-map-render map_id='map-1'][/wpv-map-render]
[wpv-map-marker map_id="map-1" marker_id="my-marker" marker_title="This is a marker" marker_field="wpcf-address"]This is the content of the marker popup.[/wpv-map-marker]

#2820992

Christopher Amirian
Supporter

Languages: English (English )

Hi,

Welcome to Toolset support. Yes, it is possible to render a map using Divi and Toolset. The key points are:

- Use a Code module (not Text) so Divi doesn’t wrap the shortcodes in extra <p> tags.

- Place [wpv-map-render] first, then the [wpv-map-marker] for the current post.

- Make sure your address field is a Toolset Address field (or pass a plain-text address with marker_address).

- Toolset → Settings → Maps: add your Google Maps API key and enable loading on the front-end.

Something like this:

[wpv-map-render map_id="map-1" width="100%" height="380px" fitbounds="on"][/wpv-map-render]

[wpv-map-marker
  map_id="map-1"
  marker_id="marker-[wpv-post-id]" 
  marker_title="[wpv-post-title]"
  marker_field="wpcf-address"]
  [types field="address"][/types]
[/wpv-map-marker]

Notes:

- marker_id="marker-[wpv-post-id]" keeps the marker ID unique per post.

- The content between [wpv-map-marker]…[/wpv-map-marker] is the popup content; you can include any fields there.

- If your address field slug differs, change marker_field="wpcf-address" accordingly.

For more information:

https://toolset.com/course-lesson/using-toolset-with-divi/

Thanks.