This hook in WP Maps Pro allows developers to customize the functionality of displaying map locations at runtime. It is triggered when there is a need to filter or limit the locations shown on a map.
Usage
Developers can implement this hook in the functions.php file of their theme or within a custom plugin. It allows for dynamic modification of location display criteria, such as showing only certain categories of locations or limiting the number of locations shown.
Example 1
Limit the number of locations displayed on the map to 5.
add_filter('wpgmp_location_criteria', 'limit_locations_on_map', 10, 2); function limit_locations_on_map($location_criteria, $map) { $location_criteria['limit'] = 5; return $location_criteria; }
Example 2
Show only locations belonging to a specific category on the map.
add_filter('wpgmp_location_criteria', 'show_specific_category_locations', 10, 2); function show_specific_category_locations($location_criteria, $map) { $location_criteria['category__in'] = array(3); // Replace 3 with your desired category ID return $location_criteria; }
Example 3
Ensure all locations are displayed without any limitation or category filter.
add_filter('wpgmp_location_criteria', 'show_all_locations', 10, 2); function show_all_locations($location_criteria, $map) { $location_criteria['show_all_locations'] = true; $location_criteria['category__in'] = false; $location_criteria['limit'] = 0; return $location_criteria; }
Tip: Always validate and sanitize input data to ensure secure usage of hooks and prevent potential security vulnerabilities.