wpgmp_marker_image_markup - WP Maps Pro

15000+ live websites are using this google maps wordpress plugin.

wpgmp_marker_image_markup

This hook allows developers to customize the HTML output of a marker image in the WP Maps Pro plugin. It is triggered when the marker image is being rendered, enabling modifications to its HTML structure before display.

Usage

Developers can implement this hook in their theme’s functions.php file or via a custom plugin to alter the marker image HTML dynamically. This is particularly useful for adding custom attributes or wrappers around the marker image.

Example 1

Modify the marker image HTML to include a custom CSS class for styling purposes.

add_filter(‘wpgmp_marker_image_markup’, function($marker_image, $location, $map_id) {
return ‘

‘ . $marker_image . ‘

‘;
}, 10, 3);

Example 2

Change the marker image HTML to include a data attribute with the location ID for JavaScript interactions.

add_filter(‘wpgmp_marker_image_markup’, function($marker_image, $location, $map_id) {
return ‘‘;
}, 10, 3);

Example 3

Wrap the marker image in a link that points to a specific URL derived from the location data.

add_filter(‘wpgmp_marker_image_markup’, function($marker_image, $location, $map_id) {
$url = ‘https://example.com/location/’ . $location[‘slug’];
return ‘‘ . $marker_image . ‘‘;
}, 10, 3);

Tip: Always sanitize and validate any data being output to ensure security and prevent XSS vulnerabilities.

Install Plugin Now!

Buy this plugin exclusively on CodeCanyon! You’ll get free updates, full support, and if you’re not satisfied, we’ve got you covered with a 30-day money-back guarantee.