Skip to content Skip to sidebar

This thread is resolved. Here is a description of the problem and solution.

Problem:
You need a simple language switcher with your own styling, but WPML is loading 90 default styles that you have to override.
Solution:
If you're implementing a custom language switcher and need to prevent WPML's default styles from loading, you can modify the code in your site. Specifically, you can edit the

styleLanguageSwitcher

function in the file

/wp-content/plugins/sitepress-multilingual-cms/classes/block-editor/Loader.php

. Here's how you can adjust the function:

private function styleLanguageSwitcher() {<br />    if ( in_array( self::BLOCK_LANGUAGE_SWITCHER, $this->cssLoaded, true ) ) {<br />        return \'\';<br />    }<br /><br />    this->cssLoaded[] = self::BLOCK_LANGUAGE_SWITCHER;<br />    $css = file_get_contents(<br />        WPML_PLUGIN_PATH . \'/dist/css/blocks/language-switcher.css\'<br />    );<br /><br />    return $css ?: \'\';<br />}<br />

Add the following code within this method to check if the constant

ICL_DONT_LOAD_LANGUAGE_SELECTOR_CSS

is defined, and if so, return nothing, effectively stopping the CSS from loading:

if (defined('ICL_DONT_LOAD_LANGUAGE_SELECTOR_CSS')) {<br />    return \'\';<br />}

This solution might be outdated or not applicable to your specific case. We highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If this does not resolve your issue, please open a new support ticket at WPML support forum.

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 30 replies, has 1 voice.

Last updated by wdburgdorf 1 month, 1 week ago.

Assisted by: Paola Mendiburu.

Author Posts
July 21, 2025 at 7:59 am #17254020

Paola Mendiburu
WPML Supporter since 11/2020

Languages: English (English ) Spanish (Español ) Italian (Italiano )

Timezone: Europe/Madrid (GMT+02:00)

Hi there!

We have release this errata regarding your problem:
https://wpml.org/errata/gutenberg-language-switcher-block-still-adds-inline-css-styles-when-the-default-styles-are-disabled/

Please let me know if you have any problem.

July 24, 2025 at 6:50 am #17266014

wdburgdorf

All good now. Thank you!