wpgmp_listing_css_class - WP Maps Pro

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

wpgmp_listing_css_class

This hook allows developers to add a custom CSS class to the listing container in the WP Maps Pro plugin. It is triggered when the listing container is being generated, enabling runtime customization.

Usage

Developers can implement this hook in their theme’s functions.php file or a custom plugin. It is useful for dynamically altering the appearance of map listings by injecting specific CSS classes based on certain conditions or preferences.

Example 1

Add a custom class to all map listings to apply uniform styling.

add_filter('wpgmp_listing_css_class', function($class, $map) {
    $class .= ' custom-map-listing-class';
    return $class;
}, 10, 2);

Example 2

Apply a different CSS class based on a specific map ID.

add_filter('wpgmp_listing_css_class', function($class, $map) {
    if($map->map_id == 123) {
        $class .= ' special-map-class';
    }
    return $class;
}, 10, 2);

Example 3

Append multiple classes conditionally to enhance styling flexibility.

add_filter('wpgmp_listing_css_class', function($class, $map) {
    $class .= ' base-class';
    if($map->map_type == 'satellite') {
        $class .= ' satellite-view';
    }
    if($map->map_zoom_level > 10) {
        $class .= ' high-zoom';
    }
    return $class;
}, 10, 2);

Always ensure that the added class names are unique and do not conflict with existing styles to maintain consistent display and avoid unintended results.

Install Plugin Now!

WP MAPS PRO helps you create dynamic, customizable maps using Google Maps or Leaflet — no coding required. Includes free updates, premium support, and a 30-day money-back guarantee.