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 thread is resolved. Here is a description of the problem and solution.

Problem: I want to only show the language switcher when the translation exists, otherwise i don't want any language switcher to appear.

Solution:
Go to WPML > Languages > Menu language switcher > Click the "+ Add a new Language switcher to a menu"
proceed according to the option of your choice:

1) "List of languages" option (checked in the "Language menu items style" section):de-select the "Current language" option.

2) "Dropdown" option: Add this code into your customizer's Custom CSS section

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

Relevant Documentation: https://wpml.org/tutorials/language-switchers/

This topic contains 2 replies, has 2 voices.

Last updated by ericD-31 1 year ago.

Assigned support staff: Alejandro.

Author Posts
October 12, 2018 at 5:20 pm #2812797

ericD-31

1. I want to turn on the menu language switcher (on the top menu), but only on pages (we don't translate posts) where an alternative to English exists. Otherwise it just shows an English option, with no other language options, a waste of space in our menu.

2. I haven't found anything helpful.

3. Not at the moment

4. dozuki.com

Please note: we do not have a web development team to be able to leverage and 'uninstall the theme/plugins' — this is our live site and we cannot do that without interrupting our operations.

October 15, 2018 at 10:42 am #2817004

Alejandro
Supporter

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

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

Hello,
Thanks for contacting WPML Support.
I'll do my best to solve this issue.

As a reference, the options i'm about to mention are all found following this path: WPML > Languages > Menu language switcher > Click the "+ Add a new Language switcher to a menu"

There are 2 ways to achieve this:

1) This can only be achieved if you have the "List of languages" option checked in the "Language menu items style" section. in this case you just need to de-select the "Current language" option (this will always hide the "current language" menu item, though, even if there are other translations).

2) If instead you chose the "Dropdown" option, you need to do something different because this option requires to always show something (that's why the "Current Language option is checked and can't be de-selected).

There's an easier solution that works with both options mentioned above, and it requires a small css code added in WPML > Languages > Language switcher options > Additional CSS (Small blue hyperlink right after the "How to handle languages without translation" options):

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

This css code will hide the "current language" Menu item only when there are no more languages present, no matter the language switcher style ("Dropdown" or "List of languages").

Let us know how it goes and remember that you can always come back if the problem wasn't solved with the above mentioned solution. I'll gladly help you find another solution for it!

October 19, 2018 at 6:50 pm #2832856

ericD-31

Thanks Alejandro! As of right now our strange redirect rules on our site are not letting me fully test this solution, but this is very helpful for us to have in order to implement in the future.