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 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: America/Los_Angeles (GMT-07:00)

Tagged: 

This topic contains 5 replies, has 3 voices.

Last updated by Bobby 1 year, 9 months ago.

Assisted by: Bobby.

Author Posts
August 16, 2023 at 12:27 pm #14230283

sanderK-22

Hello dear support team

I'm having trouble with language switcher.
I have 2 languages: English and German in my language switcher.

When I am in English version and hoover on a language switcher and click on "English ↓" then it links me to English page again.

I would like it to be so:

I am on a English page. Then hoover on a language switcher and click "English ↓". Then only dropdown menu opens down.

My site: hidden link

How to do it?

Best regards,
Sander

August 17, 2023 at 5:54 am #14242151

Shekhar Bhandari
WPML Supporter since 03/2015

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello,

Before your ticket is assigned to one of my colleagues, please allow me to walk you through some initial debugging steps. This will help speed up the support process.

You will need to create a custom language switcher and set the first menu href to "#" or remove it.

https://wpml.org/documentation/getting-started-guide/language-setup/language-switcher-options/custom-language-switcher/

Upon searching the forum, I found a solution shared by a client so I am sharing it with you, remember this is not tested by us and no further support on this code will be provided as it's a custom code solution.

Add this code to your theme functions.php file, this will remove the href for the first item of the dropdown menu

function custom_inline_scripts() {
    if (is_admin()) return; // Don't add scripts in the admin area

    ?>
    <script type="text/javascript">
    jQuery(document).ready(function($) {
    $('.wpml-ls-item.has-sub.wpml-ls-current-language').find('a:first').removeAttr('href');
});
    </script>
    <?php
}
add_action('wp_footer', 'custom_inline_scripts');

Let me know if this helps.

Thanks

August 18, 2023 at 12:04 pm #14252267

sanderK-22

Hello

WPML > Languages > Custom language switchers > I clicked enable

How to create custom language switcher and set the first menu href to "#" or remove it?

Best Regards,
Sander

enabled.jpg
August 19, 2023 at 12:36 am #14255459

Bobby
WPML Supporter since 04/2015

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Hi there,

The custom solution shared by my colleague requires you to add this language switcher code in your theme's functions.php file and then enable the custom switcher option shown in your screenshot.

However, before going the custom solution route, have you tried changing the type of dropdown to a dropdown click one?

To do this go to WPML->Languages->Widget language switcher -> add a new and select dropdown click.

Let me know your results, please.

August 19, 2023 at 1:03 pm #14256349

sanderK-22

Hello

I added it to 2Content Bottom Widget 1".

It work like I want - when I click on it it opens a dropdown language switcher menu without link reopening a same language that currently was on.

However it is not where I want it to be and the style is different.

How to make top language switcher work and function like the bottom one.

Best Regards,
Sander

header.jpg
down.jpg
August 21, 2023 at 7:52 pm #14266683

Bobby
WPML Supporter since 04/2015

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Hi there,

To make the widget look closer to your header switcher's styling you would need some CSS.

Please use the following CSS as a starting point to quickly remove the border and make the width smaller.

wpml-ls-legacy-dropdown-click a {
border: none;
background-color: #fff;
}

.wpml-ls-legacy-dropdown-click {
width: 111px;
max-width: 100%;
}

Also, edit the widget switcher in the backend and remove the language from showing twice. Deutsch (German) uncheck "Language Name in Current Language""

Let me know your results, please.

The topic ‘[Closed] Language Switcher Link’ is closed to new replies.