Many themes and plugins bundle the Google Maps API with it, which can disrupt your performance optimization efforts. Although the Google Maps API loads asynchronously, it does significantly increase the overall load time of the page.
/* * Remove Google Maps API Call */ function disable_google_map_api($load_google_map_api) { $load_google_map_api = false; return $load_google_map_api; } $plugins = get_option('active_plugins'); $required_plugin = 'auto-location-pro/auto-location.php'; if ( in_array( $required_plugin , $plugins ) ) { add_filter('avf_load_google_map_api', 'disable_google_map_api', 10, 1); }
Write the code into functions.php and save it.
Using the code below will disable Google Maps for the entire site.
add_filter( 'avf_load_google_map_api', '__return_false' );
Write it into functions.php and save it. Using this code will disable Google Maps for the entire site, as well as embedded pages containing maps.
For more wordpress related technical articles, please visit the wordpress tutorial column to learn!
The above is the detailed content of How to disable google maps in wordpress. For more information, please follow other related articles on the PHP Chinese website!