Tell us what you are trying to do?
Is it possible show map locations from repeatable field groups on an archive page?
I have a site where I am featuring locations for different Food Establishments and categorized by different types, Restaurants, Breweries, Co-op markets etc. Some of these establishments have multiple locations.
I am using repeatable field groups to store and display the location info on the Custom Post Page. We would like to show all of the locations on the Custom Post Category Archive page on a map as well.
Originally I started using repeatable fields for the address info when I started but then realized I needed to use groups to add more info like phone numbers for each location.
Locations from this repeatable field will show on a map on the archive page (with some issues) but I do not want two sets of data for each establishment.
The archive template does not like a View inserted into it.
Is there any documentation that you are following?
Is there a similar example that we can see?
What is the link to your site?
hidden link
hidden link then select a category. Cideries, Distilleries and Wineries has a n Establishment (Victory brewing) with multiple locations.
Thanks
Kevini
Hello,
Yes, it is possible within Toolset plugins.
For example:
1) In the Toolset WordPress Archive of post type "slowfoodphilly", display the map shortcode [wpv-map-render], for example:
[wpv-map-render map_id="my-map"]
https://toolset.com/documentation/programmer-reference/maps/maps-shortcodes/#wpv-map-render
2) In the loop of above Toolset WordPress Archive, display a post view:
- Query your custom repeatable field groups
https://toolset.com/course-lesson/creating-and-displaying-repeatable-field-groups/#displaying-repeatable-field-groups
- In view's loop, display the map marker shortcode, and specific the map_id attribute as "my-map"
https://toolset.com/documentation/programmer-reference/maps/maps-shortcodes/#wpv-map-marker
For your reference.
Hello,
I tried insert a view block into the Custom post type archive template and it does not give me the option to select the repeatable group like it shows in the tutorial and like i was able to do in the Custom Post Template (See image).
Also, you had said "In the loop of above Toolset WordPress Archive, display a post view..." I cannot add a View block above the WordPress Archive as it gets automatically deleted. If I add a View Block above the Archive Output and select the Custom Post Type (without seeing the Repeatable Group) and add it there I get an error saying "Nested views creation is not supported at the moment."
I was able to insert a view with a shortcode and tried creating a View with legacy interface with no success there either.
Thanks
Kevin
Please try to setup the child post view with classic editor, if you still need assistance for it, please provide your website credentials in below private message box, also point out the problem page URL and view URLs, I can setup a demo for you.
Thanks for the details, I have done below modifications in your website:
1) Edit the WordPress Archive "Snail of Approvals Archive Page Template":
hidden link
a) Remove the "Fields and Text" block
b) In the loop, add a "Fields and Text" block, display the post view shortcode:
[wpv-view name="snail-repeatable-field"]
See my screenshot snail-repeatable-field.jpg
2) Edit the post view "Snail Repeatable Field Group":
hidden link
a) In section "Query Filter", change the filter to:
Select items from the Snail Location group that are a related to the current post in the loop.
b) In section "Loop Editor", change the marker shortcode as below:
[wpv-map-marker map_id='map-11' marker_id='marker-[wpv-post-id]' marker_field='wpcf-address'][/wpv-map-marker]
Test it in frontend, for example:
hidden link
It works fine, please check if it is what you want.
Hi Luo,
Thanks for your work on this although I don't think we are there yet.
The map is showing address info from the repeatable field "address". The map block settings have the ID you set but the settings use field "address" instead of "snail address" which is the group.
As a test if you go to markets (hidden link) there are six markers on the map but Moms market has four locations and only
one shows. I can change the dropdown in the Map Block to 'Snail Address" but nothing shows when i do this.
I also noticed that the view name you added in the loop was "snail-repeatable-field" however the view you edited was called "snail-repeatable-field-group". I changed that but no change.
Thanks
Kevin
Thanks for the update, I have done below modifications in your website:
1) Edit the WordPress Archive
hidden link
Change view's shortcode as blow:
[wpv-view name="snail-repeatable-field-group"]
2) Edit the post view:
hidden link
Change the marker shortcode as below:
[wpv-map-marker map_id='map-11-1' marker_id='marker-[wpv-post-id]' marker_field='wpcf-snail-address'][/wpv-map-marker]
Please test again, check if it is fixed, thanks
Hello,
I think we are getting close. Your solution seemed to work however I need to have the markers display the establishments name. When I tried to do that with the Map Block, the map would not populate and showed Africa.
So I went back to adding a Map shortcode in the template
[wpv-map-render map_id="map-12" map_height="350px"][/wpv-map-render], which works
Now I am trying to add the marker-title attribute in the View but it is not working.
I have
[wpv-map-marker map_id="map-12" marker_id="marker-[wpv-post-id]" marker_field="wpcf-snail-address" marker_title="[wpv-post-title]"][/wpv-map-marker]
Also if I am using the shortcode to render a map is it possible to style it with with the Silver view as available with the block?
Thanks
Kevin
I have changed the markers shortcode as below:
[wpv-map-marker map_id='map-12' marker_id='marker-[wpv-post-id]' marker_field='wpcf-snail-address' marker_title='[types field="snail-location-name"][/types]'][/wpv-map-marker]
It works fine in frontend, see my screenshot marker6.jpg
Yes, I was able to get it to work by add another field, "snail-location-name" to the repeatable field group. Then use that name to display the marker for each repeatable field group location. I assume that it is looping through the repeatable field group so it is not able to access the field "wpv-post-title" without more programming.
Is it possible to style the map with with the Silver view as available with the block?
Thanks
Kevin
Q1) I assume that it is looping through the repeatable field group so it is not able to access the field "wpv-post-title" without more programming.
Which post title do you want to display?
If it is "Snail of Approval" post title, you can display it in the child post view "Snail Repeatable Field Group" using attribute "item", for example:
[wpv-post-title item="@snail-location.parent"]
See my screenshot: post-title.jpg
More help:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/
Q2) Is it possible to style the map with with the Silver view as available with the block?
What is the "Silver view" are we talking about?
If you want to display different map style, please follow our document to customize the map shortcode:
https://toolset.com/documentation/programmer-reference/maps/maps-shortcodes/#wpv-map-render
map_type. Optional, defaults to "roadmap". Can be "roadmap", "satellite", "hybrid", or "terrain".
Thanks that helped a lot, my issue is resolved.
As for the Silver Style, there is drop down on the Maps Block for different map styles. Its not necessary now as the client likes the default style.
OK, feel free to create new ticket if there is other new questions.
My issue is resolved now. Thank you!