[Resolved] How to display a custom map marker which is added as a term field
This thread is resolved. Here is a description of the problem and solution.
Problem:
The issue here is that the user has a CPT, however they stored their custom map markers in a Taxonomy custom field and wanted to display these custom markers on a map for their respective posts.
I have a CPT called Businesses and within that I have a Taxonomy called Sectors (of which there are 4). I would like to plot all business on a map and have it working fine, all except the custom markers.
I created a Custom Term Field for the markers called "map-marker" (image field) and have uploaded a different custom marker for each sector. I have tried multiple methods to try and pull the correct marker for each Business, but can't seem to get the custom markers to load.
To get this correctly your custom marker is stored within the taxonomy term's custom field ? Correct?
If so then you will need to create a taxonomy view that will list out the current term of the post being displayed. On that taxonomy view you will need to add a taxonomy term filter. See Screenshot
In the loop output editor of that view you will add the shortcode for the custom field that has the url for the marker.
Example
[types termmeta='marker' output='raw'][/types]
Finally you are going to ensure that the option "Disable the wrapping DIV around the View" is checked.
Once all that is completed you will now insert the view you've created in the marker option section.
Thank you for the detailed response. I now understand the logic behind creating a secondary view to get the term field and then inserting that view into the marker_icon to use the URL from the term field.
However, I am using the view on the homepage of the site, so there are no posts, and the page isn't an archive, so setting the filter as you suggested to "Set by the page where this View is shown" doesn't work.
The Map Markers are stored in a Custom Field in each Sector Taxonomy. If I stored them in the actual post, would I not have to add the correct marker in each Business individually?
View 1 – All Businesses Location Map (Post Type = Businesses, Taxonomy Filter = Select posts with taxonomy: Sectors the same as the page where this View is shown)
Sorry for the confusion but since seeing the screenshots I thought of the best way of doing this.
So in summary we will only have 2 views.
View 1:
Taxonomy view (Sectors view) has the filter for Taxonomy Term set by current post.
In the taxonomy view. The only this that will be in the view is the marker data.
This should get you up and running. I realise that I made an error in my previous post but you should Only need 2 views and outline them as I have above.
Please let me know if you are encountering any issues.
The only step that you did incorrectly was to add the filter to this view hidden link
Then you added the incorrect view as the marker_icon attribute.
I've corrected this and the proper marker info should be.
[wpv-map-marker map_id='all-businesses' marker_id='marker-[wpv-post-id]' marker_icon='[wpv-view name="get-current-sector-map-marker"]' marker_field='wpcf-google-map-location'][/wpv-map-marker]