Skip Navigation

[Resolved] Different map markers based on custom taxonomy.

This support ticket is created 3 years, 9 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: Asia/Hong_Kong (GMT+08:00)

This topic contains 11 replies, has 2 voices.

Last updated by thisen 3 years, 9 months ago.

Assisted by: Luo Yang.

Author
Posts
#1922319
map2.png
map.png

I have a custom post type “map pins”, that represents our different customers. The purpose of them is to put them on a map Block which I have here. The source for the markers is of course the View for the custom post type next to the map, where I just have a search field and taxonomy filter (I don’t need to display a list of the posts).
I’m trying to figure out how to give the markers a different pin based on the taxonomy, but I’m having some trouble. I looked around a bit for similar questions and from what I can gather, I need to use a conditional, and some additional views? I’m not exactly sure how to implement it. If you could help me in the slightest, it would be much appreciated! 😊

#1922609

Hello,

You can try with [wpv-conditional] shortcode, check if current post has specific term, then display different map marker shortcode, for example:
1) Dashboard-> Toolset-> Settings-> Front-end Content
In section "Functions inside conditional evaluations", add WordPress function: has_term

2) Use below shortcodes to display different marker shortcode:

[wpv-conditional if="(has_term('my-taxonomy', 'my-term', null) eq '1')"]
[wpv-map-marker map_id="map-1"  marker_icon="<em><u>hidden link</u></em>" marker_id='marker-[wpv-post-id]' marker_field="wpcf-address-field-slug" marker_title=" "]
[wpv-post-link]
[/wpv-map-marker]
[/wpv-conditional]

Please replace "my-taxonomy" with your custom taxonomy slug
replace "my-term" with the specific term slug
replace "map-1" with the map ID
replace "hidden link" with the specific specific marker icon URL
replace "address-field-slug" with your custom address field slug

More help:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-conditional
https://toolset.com/documentation/programmer-reference/maps/maps-shortcodes/#wpv-map-marker

#1923737

Hello, thank you for your reply.
So I've added the "has_term" function, and replaced the different slugs and id's etc. with my own values. I'm just not exactly sure where I need to place/save the shortcodes in my content or site?

#1927251

If you are using WordPress Blocks editor, you can add a shortcode block, and put those shortcodes in it.

More help:
hidden link

#1928403
marker settings.png

That's what I tried actually, but it didn't seem to do anything. The markers are still the default one. I put the shortcode block in the view loop, because I assume it has to check the conditions on every post? So far the only way that I can actually get markers on the map is if I go in the map blocks marker options and make one that has the view block as source. I don't think it's overwriting what the shortcodes is supposed to do, because if I remove it and just keep the shortcodes, no markers get placed anyway.

My shortcodes look as such:

 [wpv-conditional if="(has_term('sap-user-type', 'sap-customer-roll-in', null) eq '1')"]
[wpv-map-marker map_id="sap-i-dk-map"  marker_icon="<em><u>hidden link</u></em>" marker_id='marker-[wpv-post-id]' marker_field="wpcf-address" marker_title=" "]
[wpv-post-link]
[/wpv-map-marker]
[/wpv-conditional]
#1928981

It works fine in my localhost, please provide a test site with the same problem, also point out the problem page URLs, I can setup a demo for you.

#1932609

I have tried the credentials you provided above, but got this message:

An Authentication Code has been sent to the email address associated with your account. Look for an email with "Login Authentication Code" in the subject line.

Please check it, make sure it is a valid admin account, you might need to deactivate "Authentication Code" plugin

#1933013

Sorry, oversight on my part. Should be good to log in now. Else let me know again.

#1933029

I'm not sure why but it keeps asking for authentication (I just tried with the account myself) even if I've disabled it. I'm probably overlooking something. I'll let you know when it's disabled.

#1933049

Okay, it was a setting in iThemes that forced a two-factor authentication for specifically administrators, even if it was disabled on the account... I checked and could log in in without two-factor, so it should (finally) be ready. Sorry for the inconvenience. 🙂

#1934451

Thanks for the details, I have modified the shortcodes to:

[wpv-conditional if="(has_term('sap-customer-roll-in', 'sap-user-type', null) eq '1')" ]
[wpv-map-marker map_id="sap-i-dk-map"  marker_icon="<em><u>hidden link</u></em>" marker_id='customer-marker' marker_field="wpcf-address" marker_title=" "]
[wpv-post-link]
[/wpv-map-marker]
[/wpv-conditional]

Please test again, check if it is fxed.

More help:
https://developer.wordpress.org/reference/functions/has_term/

#1938115

Seems to do the trick, thank you so much!