Problem:
The issue here is that the user wanted to have custom map markers based on the taxonomy that is attached to the post.
Solution:
In order to do this you will need to make use of the has_term() function. This function return 1 or 0 where 1 is true and 0 is false.
It will check if your post has the term you want attached to it.
Example usage with different markers.
[wpv-conditional if="(has_term('irish-cottage-for-sale', 'listing-type', null) eq '1')"] [wpv-map-marker map_id='map-1' marker_id='marker-[wpv-post-id]' marker_field='wpcf-address_ts' marker_icon='https://cottageology.com/wp-content/uploads/2019/05/red-marker.png'] <span class="marker-feat-img">[wpv-post-featured-image size="medium"]</span><h3>[wpv-post-title]</h3><a class="et_pb_button" href="[wpv-post-url]">View Details</a> [/wpv-map-marker] [wpv-conditional if="(has_term('irish-cottage-for-rent', 'listing-type', null) eq '1')"] [wpv-map-marker map_id='map-1' marker_id='marker-[wpv-post-id]' marker_field='wpcf-address_ts' marker_icon='https://cottageology.com/wp-content/uploads/2019/05/green-marker.png'] <span class="marker-feat-img">[wpv-post-featured-image size="medium"]</span><h3>[wpv-post-title]</h3><a class="et_pb_button" href="[wpv-post-url]">View Details</a> [/wpv-map-marker] [/wpv-conditional]
As you can see from the above we are checking 2 different terms in the listing type taxonomy, irish-cottage-for-rent and irish-cottage-for-sale . These are actually the slugs of the terms.
Next all we did was to provide a different marker_icon url for each.
In order for the has_term function to work you need to add it to the custom functions arguments in Toolset -> Settings > Frontend.
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 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | - |
- | 13:00 – 18:00 | 13:00 – 18:00 | 13:00 – 18:00 | 14:00 – 18:00 | 13:00 – 18:00 | - |
Supporter timezone: America/Jamaica (GMT-05:00)
This topic contains 34 replies, has 2 voices.
Last updated by 5 years, 7 months ago.
Assisted by: Shane.