wpgmp_listing_html - WP Maps Pro

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

wpgmp_listing_html

This hook in the WP Maps Pro plugin allows developers to modify the HTML of listing items displayed below the map. It provides flexibility to change how listings are presented by altering the HTML structure dynamically.

Usage

Developers can implement this hook in their theme’s functions.php file or in a custom plugin to change the layout or content of the listing items. By hooking into this filter, you can customize the output by modifying the HTML structure or adding additional data to the listings.

Example 1

This example demonstrates how to add a custom CSS class to the listing items for styling purposes.

add_filter('wpgmp_listing_html', 'custom_listing_html_class', 10, 2);
function custom_listing_html_class($html, $map) {
    return str_replace('<div class="listing-item">', '<div class="listing-item custom-class">', $html);
}

Example 2

In this example, we append additional information, such as a contact number, to each listing item.

add_filter('wpgmp_listing_html', 'append_contact_info', 10, 2);
function append_contact_info($html, $map) {
    $contact_info = '<p>Contact: 123-456-7890</p>';
    return $html . $contact_info;
}

Example 3

This example shows how to conditionally modify the listing HTML based on the category display format.

add_filter('wpgmp_listing_html', 'conditional_html_modification', 10, 2);
function conditional_html_modification($html, $map) {
    global $wpgmp_categorydisplayformat;
    if ($wpgmp_categorydisplayformat == 'grid') {
        $html = '<div class="grid-item">' . $html . '</div>';
    }
    return $html;
}

Tip: Always sanitize and validate any data before displaying it in the HTML to prevent security vulnerabilities such as XSS (Cross-Site Scripting).

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.