Programmatically change single map language based on the URL’s language attribute

In this tutorial, you’ll see how to change the single map’s # default language using a URL language attribute.

Edit the file “functions.php” of your theme/child theme and copy/paste the code below, then, adapt it to your needs:

function cspm_change_single_map_lang(){
		$ProgressMapClass = CSProgressMap::this();
            $ProgressMapClass->gmaps_formatted_url = str_replace($ProgressMapClass->map_language, esc_attr($_GET['lang']), $ProgressMapClass->gmaps_formatted_url);
add_action('template_redirect', 'cspm_change_single_map_lang');

In this code, you may need to edit the name of the URL language attribute lang to the one you are using in your URL.

For example, to change the URL language attribute to i18n, locate the code:


change it to:


In the same context