I'd like the map to display a different pin depending on the post's taxonomy.
I've tried following the steps in this thread, without success: > https://toolset.com/forums/topic/different-map-marker-for-each-of-the-terms-within-a-taxonomy-on-map-view/
For more information:
- I've enabled the has_term filter
- I've removed the marker that appears in the toolset block
I want to achieve something similar to this: > lien caché
Where each map icon indicates the taxonomy of the product type associated with that post.
The site under development is lien caché
You can find the map here: > lien caché
Another thing to keep in mind is that I don't want to lose the pop-up functionality when clicking on the pin.
Thanks,
Hi,
Welcome to Toolset support.
For different map pins based on a post taxonomy, the approach from that forum thread is still the right direction: remove the marker from the Map block settings and add the marker shortcode manually inside the View loop, wrapped in conditional checks for each taxonomy term.
The marker shortcode supports the marker_icon attribute, and the popup content is whatever you place between the opening and closing [wpv-map-marker] shortcode, so you should not lose the popup functionality if the shortcode is added correctly. For more information:
https://toolset.com/documentation/programmer-reference/maps/maps-shortcodes/#wpv-map-marker
Example structure:
[wpv-conditional if="( has_term('term-slug-1', 'taxonomy-slug', null) eq '1' )"]
[wpv-map-marker map_id="map-1" marker_id="marker-[wpv-post-id]-term-1" marker_field="wpcf-address-field-slug" marker_icon="<em><u>lien caché</u></em>"]
Popup content here
[/wpv-map-marker]
[/wpv-conditional]
[wpv-conditional if="( has_term('term-slug-2', 'taxonomy-slug', null) eq '1' )"]
[wpv-map-marker map_id="map-1" marker_id="marker-[wpv-post-id]-term-2" marker_field="wpcf-address-field-slug" marker_icon="<em><u>lien caché</u></em>"]
Popup content here
[/wpv-map-marker]
[/wpv-conditional]
Please replace:
- taxonomy-slug with your product type taxonomy slug
- term-slug-1 / term-slug-2 with the actual term slugs
- wpcf-address-field-slug with the Toolset address field slug
- map-1 with the actual map ID from your Map block
- the icon URLs with the final marker image URLs
Also, please see if this would help:
https://toolset.com/forums/topic/custom-marker-for-each-categorie-taxonomy/
Thanks
Thanks!
I was able to get what I wanted. I think my mistake was that I was putting two HTML blocks inside the loop, one to generate the map marker and another to generate an information sheet with the post summary. Could this be why it wasn't working?
Anyway, thanks for the quick support!