This hook in WP Maps Pro allows developers to add custom HTML or functionality directly after the map element’s div. It is triggered after the map has been rendered on the page.
Usage
Developers can implement this hook in their theme’s functions.php file or through a custom plugin. It is particularly useful for adding content or scripts that need to be positioned directly after the map. Understanding the parameters and ensuring compatibility with the rest of your code is crucial.
Example 1
Adding a custom message after the map to prompt users to take action.
add_action('wpgmp_after_map', 'add_custom_message_after_map', 10, 2); function add_custom_message_after_map($map_id) { echo '<div class="custom-message">Explore the map to find interesting locations!</div>'; }
Example 2
Injecting a custom script for tracking user interactions with the map.
add_action('wpgmp_after_map', 'add_tracking_script_after_map', 10, 2); function add_tracking_script_after_map($map_id) { echo '<script>console.log("Map with ID ' . $map_id . ' has been displayed.");</script>'; }
Example 3
Appending a button that links to additional resources related to the map content.
add_action('wpgmp_after_map', 'add_resource_button_after_map', 10, 2); function add_resource_button_after_map($map_id) { echo '<a href="https://example.com/resources" class="resource-button">More Resources</a>'; }
Tip: Always validate and sanitize any data that is output using this hook to prevent security vulnerabilities. Consider the impact of additional content on the user experience and page load times.