Skip Navigation

[Resolved] Custom Marker based on taxonomy

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/Karachi (GMT+05:00)

This topic contains 8 replies, has 2 voices.

Last updated by rubenM-3 1 year, 12 months ago.

Assisted by: Waqar.

Author
Posts
#2502255

Hi,
I'd like to have a custom marker based on my custom taxonomy "tipus".

I've tried this:
https://toolset.com/forums/topic/different-map-markers-based-on-custom-taxonomy/
https://toolset.com/forums/topic/different-map-markers/
https://toolset.com/forums/topic/different-custom-marker-in-a-map-based-on-a-custom-taxonomy/

With no luck. I've a page with a View and a Map. This view has a loop, with classic editor, and there I use my conditionals

<div class="is-layout-flex wp-container-19 wp-block-columns list-ubicacio tipus-[wpv-post-taxonomy type="tipus" format="slug"]">
<div class="is-layout-flow wp-block-column list-image" style="flex-basis:55%">
[wpv-conditional if="( '[wpv-post-featured-image output="url"]' ne '' )"][wpv-post-featured-image size="custom" width="500" height="350" crop="true"][/wpv-conditional]
[wpv-conditional if="( '[wpv-post-featured-image output="url"]' eq '' )"]MaresmeEvents[/wpv-conditional]
</div>

<div class="is-layout-flow wp-block-column list-data">
<h2 class="has-text-align-left">
[wpv-post-title]</h2>
<p class="list-claim">[types field='frase-descriptiva'][/types]</p>
<div class="is-layout-flex wp-container-17 wp-block-columns">
<div class="is-layout-flow wp-block-column" style="flex-basis:33.34%">
[wpv-conditional if="( $(wpcf-safe-travel) eq '1' )"]<img decoding="async" loading="lazy" src="hidden link" alt="" class="list-icona">[/wpv-conditional]</div>
<div class="is-layout-flow wp-block-column" style="flex-basis:33.34%">
[wpv-conditional if="( $(wpcf-safe-travel) eq '1' )"]<img decoding="async" loading="lazy" src="hidden link" alt="" class="list-icona">[/wpv-conditional]
</div>
<div class="is-layout-flow wp-block-column" style="flex-basis:33.33%"></div>
</div>
<div class="tb-fields-and-text tipus" data-toolset-blocks-fields-and-text="3e1d2592ce20bdf2bf813c9dfa44c991">
<p>[wpv-post-taxonomy type="tipus"]</p>
</div>
<div class="capacitat">
[types field='capacitat' format='FIELD_VALUE'][/types] <span class='et-pb-icon'></span>
</div>

</div>
</div>
[wpv-conditional if="( has_term('Incentius', 'tipus', null) eq 1)"]
[wpv-map-marker map_id='map-12' marker_id='marker-[wpv-post-id]' marker_field='wpcf-adreca' marker_icon='//my-domain/wp-content/uploads/2022/11/POI_incentius.png'][wpv-post-title][/wpv-map-marker][/wpv-conditional]
[wpv-conditional if="( has_term('Gastronomia', 'tipus', null) eq 1)"]
[wpv-map-marker map_id='map-12' marker_id='marker-[wpv-post-id]' marker_field='wpcf-adreca' marker_icon='//my-domain/wp-content/uploads/2022/11/POI_gastronomia.png'][wpv-post-title][/wpv-map-marker][/wpv-conditional]
[wpv-conditional if="( has_term('Allotjaments', 'tipus', null) eq 1)"]
[wpv-map-marker map_id='map-12' marker_id='marker-[wpv-post-id]' marker_field='wpcf-adreca' marker_icon='//my-domain/wp-content/uploads/2022/11/POI_allotjaments.png'][wpv-post-title][/wpv-map-marker][/wpv-conditional]

"tipus" is my taxonomy.
I also declared has-term as frontend and conditional.

My page is hidden link
Thank you!

#2502711

Hi,

Thank you for contacting us and I'd be happy to assist.

To troubleshoot this, I'll need to see how this view is set up in the admin area. Can you please share temporary admin login details, in reply to this message?

Note: Your next reply will be private and making a complete backup copy is recommended before sharing the access details.

regards,
Waqar

#2503785

Hi Waqar,
did you see my credentials?

Thank you!

#2503917

The admin access details worked, thank you.

I'm currently running some tests on my website with a similar setup and will share the findings, as soon as this testing completes.

Thank you for your patience.

#2506217

Thank you for waiting.

During troubleshooting, I was able to make the conditional statements work, after the following changes:

1. The function name added at WP Admin -> Toolset -> Settings -> Front-end Content, was "has-term" when it should be 'has_term'. I've added the correct one now.
( screenshot: hidden link )

2. The taxonomy name 'Tipus' in the conditional statement needed to be changed to the taxonomy slug 'tipus'.

For example:


[wpv-conditional if="( has_term('Incentius', 'Tipus', null) eq 1)"]

Becomes:


[wpv-conditional if="( has_term('Incentius', 'tipus', null) eq 1)"]

You can see the different map markers being used on the page, after these changes.

#2506251
Captura de pantalla 2022-11-29 a las 16.21.38.png

Hi Waqar,
this looks very well! I've been able to insert my marker, but I don't know why it seems to be a normal, a default marker, besides it. I attach you an image. Maybe I have to adjust custom marker size? Now it's a 22x32 px transparent PNG.

Thank you!

#2506263
Captura de pantalla 2022-11-29 a las 16.34.54.png

Hi,
in fact, now it seems that my marker is besides the default one. Do I need to do something in Map in page, in block editor? Also, it seems default zoom is very big, but this seems another issue.

Thanks,

#2506677

The default map markers were coming from the settings of the "Map" block used in the page's content.
( screenshot: hidden link )

I've unset that option and now only the conditional map markers coming from the view's loop are showing.

As for the map's default zoom level, it can be controlled from the same "Map" block's settings too. Currently, the "Adjust zoom and center to show all markers at once" option is checked, which automatically sets the initial zoom level based on the available map markers so that they all can fit it.

If you'll disable that option, you'll see the option to manually set the initial zoom level.

#2506749

Great! It works, thank you!