Use a Different Marker For Each Location

Using a different marker for each location requires the creation of a custom meta field. You can use this to provide a URL to the marker image you’d like to use instead of the default one from the settings page.

All code needs to go in the functions.php inside your active theme folder.

Create a New Custom Meta Field

You can create a new meta field with the wpsl_meta_box_fields filter. It allows you to add custom fields to existing tabs, or place them under a new one.

In the above example, the new field is placed under the existing Additional Information tab on line 18. If you’d like to place it under a new tab, you can use the code below instead.

The default marker format is 48 x 70 pixels, but you can change this with the wpsl_marker_props filter. If you use a bigger image, it will be scaled down.

Include the Custom Marker in the Search Results

The next step is to make sure data from the custom meta field is included in the returned search results on the front-end. The filter you need for this is the wpsl_frontend_meta_fields filter.

The value you for the name=”” on line 6 is normally something you can set to whatever you want, but in this case, it’s required to set it to alternateMarkerUrl.

If you don’t do this, the JS code that handles the creation of the markers will not use the custom marker URL. Instead, you will see the marker you selected on the settings page.

Use the Custom Marker on the Single Store Pages

If you’ve enabled the permalink option on the settings page, then you will need additional code to make the custom markers also show up on the single store pages. This is done with the wpsl_cpt_info_window_meta_fields filter.

If the changes you made don't show up on the frontend, then make sure to flush the store locator transient cache. You can do this on the settings page.