Skip Navigation

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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 -

Supporter timezone: Asia/Singapore (GMT+08:00)

This topic contains 3 replies, has 2 voices.

Last updated by Kor 6 months, 2 weeks ago.

Assisted by: Kor.

Author Posts
May 1, 2024 at 10:58 pm #15585002

geraldoP-2

I want to hide the switcher if a page only has one language, which in our case is English.

Most of the articles in our blog are in English, and just a few posts are translated. We want to hide the switcher (widget) when no other language is available besides English.

This article below, for example, is only in English. So, no need to have the language switcher as no other flag (language) will be avialble to switch the page to.

hidden link

This is our blog where we use WPML: hidden link

How can the switcher disappear when only the default language (English in this case) is available?

May 3, 2024 at 9:37 am #15590585

Kor
Supporter

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Hello,

Thank you for getting in touch. Achieving this might require custom CSS coding. Could you please provide a link to a post that has been translated into multiple languages? This will allow me to assess if your requirements can be met without intricate customization.

May 3, 2024 at 2:16 pm #15591739

geraldoP-2

Hi Kor,

It will need custom CSS? It's just a simple feature and should be native to WPML.

This is a page that's translated into multiple languages: hidden link

May 3, 2024 at 4:25 pm #15592139

Kor
Supporter

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Thank you for your response.

You have two options to address the language switcher:

1. You can create a new custom language switcher following the instructions outlined here: https://wpml.org/documentation/getting-started-guide/language-setup/language-switcher-options/custom-language-switcher/ and write a custom PHP script to achieve what you needed there.

2. Alternatively, you can hide the language switcher if it's not translated using the provided custom CSS code. Simply insert the following CSS code into WP > Appearance > Customize > Additional CSS:

.wpml-ls-first-item.wpml-ls-last-item {
    display: none!important;
}

DISCLAIMER: Please know that any snippet or code suggested here is for educational purposes only. they are not meant to be the final solution but instead meant to point you in the right direction and are out of the scope of our support so we can't nor will modify, improve, debug or maintain it.

The topic ‘[Closed] Hide switcher if only one language is available’ is closed to new replies.