The wpgmp_listing hook in the WP Maps Pro plugin allows developers to modify the settings of the listing displayed below the map. This hook provides a way to customize the appearance and functionality of location listings dynamically.
Usage
Developers can implement this hook in their WordPress theme or plugin to override or customize the listing settings at runtime. It is particularly useful for tailoring the user experience by adjusting how location data is presented or filtering options are applied.
Example 1
Modify the default number of locations displayed per page in the listing.
add_filter('wpgmp_listing', 'custom_listing_per_page', 10, 2); function custom_listing_per_page($listing_settings, $map) { $listing_settings['pagination']['listing_per_page'] = '5'; return $listing_settings; }
Example 2
Enable the search form and category filter for the listing below the map.
add_filter('wpgmp_listing', 'enable_search_and_category_filter', 10, 2); function enable_search_and_category_filter($listing_settings, $map) { $listing_settings['display_search_form'] = true; $listing_settings['display_category_filter'] = true; return $listing_settings; }
Example 3
Change the default sorting option to sort by category in descending order.
add_filter('wpgmp_listing', 'modify_default_sorting_option', 10, 2); function modify_default_sorting_option($listing_settings, $map) { $listing_settings['default_sorting'] = array('orderby' => 'category', 'inorder' => 'desc'); return $listing_settings; }
Tip: Always ensure that the modifications to the listing settings are thoroughly tested to provide a seamless user experience and to avoid any conflicts with other plugins or theme functionalities.