Skip to content
OSULZER.AT
Code1 min read· updated February 14, 2026

WPML: Current Language as a CSS Class in the Body Tag

A code snippet that adds a class with the name of the current language to your HTML body tag, so you can style individual language versions differently.

The following code snippet lets you add a class with the name of the current language to your HTML body tag. This makes it possible, for example, to change the styling specifically for the English version of your website.

function osulzer_add_language_class_to_body($classes){
	if(defined(ICL_LANGUAGE_CODE)) { #check if wpml constant is present
		$classes[] = 'lang-'.ICL_LANGUAGE_CODE; 
  		return $classes;
	}
}

add_filter('body_class', 'osulzer_add_language_class_to_body');

With CSS, you can then control the content, for example as follows. As an example, we simply hide the header for the German version of the site.

.lang-de header {
    display:none;
}

Learn more about my services as a WordPress developer.

PHP Freelancer

Prefer to have it done for you?

Customizations, plugins, and integrations - cleanly implemented, €120/h plus VAT.

See the PHP freelancer

New project?

Contact.

Tell me briefly about your project - I'll get back to you personally.

Your data is used solely to handle your inquiry. More in the privacy policy.