Skip Navigation

[Resolved] Maps within views on archive pages

This support ticket is created 4 years, 3 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.

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: Africa/Casablanca (GMT+01:00)

This topic contains 1 reply, has 2 voices.

Last updated by Jamal 4 years, 3 months ago.

Assisted by: Jamal.

Author
Posts
#2002439
Skærmbillede 2021-03-26 kl. 23.28.00.png

Hey,

I hope this question has not been answered before, thanks in advance.

I want to make an archive where the elements within archive loop contains a map with a marker, based on a dynamic address or coordinates. So very ordinary, but with a map instead of a featured image.

However, I'm getting the following message when adding the map block:

Map block cannot be inside the View block. If you want map markers to come from a View, place the Map block outside the View and in the Marker section, select View block for the Source for the marker option.

This is not possible, or is there something I have missed? Maybe a more detailed description of how I actually do it

#2002673

Hello and thank you for contacting the Toolset support.

Indeed, you can't add a map block inside a view. The view needs to be outside of the view, which means that you can't have a map per post in the view.

However, we can work around this limitation using a content template or using shortcodes. I run a small test on this test site and I was able to implement both techniques:
- Using a content template: Create a content template and assign it to the post type. This will let you choose the marker dynamic source. Check this screenshot hidden link Then you can unassign the content template from the custom post type. Use this content template inside the view.
- Use Maps shortcodes, inside a Fields&Text block, instead of a map block.

Use the following link to login to my test site hidden link

For the first technique:
- Content template: hidden link
- Page with the view: hidden link
- Result: hidden link

For the second technique(easiest technique):
- Page with the view: hidden link
- Result: hidden link
The used shortcodes are:

[wpv-map-render map_id="map-[wpv-post-id]"][/wpv-map-render]
[wpv-map-marker map_id='map-[wpv-post-id]' marker_id='marker-[wpv-post-id]' marker_field='wpcf-location'][/wpv-map-marker]

You can insert the Maps shortcodes using Toolset interface. Check these screenshots hidden link hidden link

Read more about the Maps shortcodes https://toolset.com/documentation/programmer-reference/maps/maps-shortcodes/
Note that I have used the wpv-post-id shortcode in the map and the marker IDs to make them dynamically unique.

I hope this helps. Let me know if you have any questions.