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.

Tagged: 

This topic contains 10 replies, has 0 voices.

Last updated by ukuS 9 minutes ago.

Assisted by: Itamar.

Author Posts
January 19, 2025 at 12:04 pm #16610387

ukuS

Hi

I managed to subscribe but now the issue is that the language switcher (flags on the top right corner of the site) are not leading to the pages as before. Please check this link hidden link and if to then click on the three flags (Finnish, Latvian, Lithuanian) on the top right corner you will see that it doesn’t work. I don’t know what exactly happened as it was working before upgrading to paid version of WPML. I have added the correct links where these flag buttons should lead to in the Customize - Settings - Custom code section.

Could you please help with this?

Thanks

January 19, 2025 at 12:33 pm #16610409

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+02:00)

Hi,

I can see this problem on your site.

For the Finnish language, I get this message:

Welcome!
I'm the fox of Veebimajutus.ee and welcome you here. Website is not ready yet, but the owner of the page is working hard to bring it to you as quickly as possible.

Please see the attached screenshot.

If you have a folder named /fi/ in your WordPress installation, this might be the reason for this. You should delete this folder because this might interfere with WPML's Language URL format of Languages Directories.

**** Important! Please make a full site backup (files and DB) before you proceed with those steps****

Other than that, please ensure that the homepage for the Finnish, Latvian, and Lithuanian languages is published.

If it does not help and you need further help with this, please share the access details to your site with me. I'm enabling a private message for the following reply.
Privacy and Security Policy
We have strict policies regarding privacy and access to your information. Please see:
https://wpml.org/purchase/support-policy/privacy-and-security-when-providing-debug-information-for-support/
**IMPORTANT**
- - Please backup the site files and database before providing us access. --
-- If you have a staging site where the problem can be reproduced, it is better to share access to the staging site.--

Regards,
Itamar.

2025-01-19_14-23-40.jpg
January 20, 2025 at 12:20 pm #16613307

ukuS

Hi Itamar

Let me explain in more detail.
Those flags on the top right corner were working a bit differently for us.
Only the Estonian and English flags lead to our actual website translated sections.
The Finnish, Latvian and Lithuanian flags are supposed to link to an external site of our partners. These are located in other server and are not part of our WordPress.

So we have previously added this code to our Customize - Settings - Custom code section:

});
jQuery("a img[alt=fi]").parent().attr("href", "hidden link");
jQuery("a img[alt=lv]").parent().attr("href", "hidden link");
jQuery("a img[alt=lt]").parent().attr("href", "hidden link");
jQuery(".video-popup-content").on("click", function() {

There you see those links where each flag should direct to.

It doesn't work anymore. Do you know can we solve this is with the flags? If we don't have those translations in these languages but want those flags to direct to our partners external websites, what should we do?

NB. I haven't yet created a back-up of anything. Do you need to log in to our WordPress to check the possible solutions?

Thank you
Uku

January 20, 2025 at 3:13 pm #16614293

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+02:00)

Hi, Uku.

Thanks for adding this important information.

If the Finnish, Latvian, and Lithuanian flags are supposed to link to external sites, then you should remove them from WPML. In other words, they should not be added as secondary languages. This can be done in WPML -> Languages -> Site Languages, and click the Add/Remove Languages button.

Then, you need to create a custom Language Switcher by following the instructions in our guide here.

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

The above guide only gives some simple examples. You will need your custom Language Switcher to combine Estonian and English (the languages added by WPML) and the external links you need to the Finnish, Latvian, and Lithuanian websites.

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

If you have further questions or doubts about what we explain in the above guide, we will happily answer them. If something is not working in the custom Language Switcher you created, we will be glad to take a look and say what might be the problem.

Otherwise, if you need further help with what you are trying to achieve, I would suggest you consider contacting one of our certified partners from this link:

https://wpml.org/contractors/

Before doing so, please have a look also here:

https://wpml.org/documentation/about-wpml-contractors/what-type-of-work-you-can-expect-from-contractors/

With our contractors, you might get the custom assistance you need to get on with your project.

Regards,
Itamar.

January 21, 2025 at 10:12 am #16617581

ukuS

Hello
Thanks for the info.
But can I create external links to the Finnish, Latvian, and Lithuanian websites by following this guide that you sent? I didn't see there this option to add an external link behind the language flag.

Thanks
Uku

January 22, 2025 at 3:22 pm #16623934

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+02:00)

Hi, Uku.

As I mentioned, you will need custom work to achieve this, which is out of the scope of our support forum. However, I asked our second-tier supporters if they could provide a sample code for your needs. I'll update you here once I have their reply.

I appreciate your patience.
Itamar.

January 22, 2025 at 4:54 pm #16624449

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+02:00)

Hi,

Here is a code you can add to the functions.php file of your theme that is supposed to help you with what you are trying to achieve.

function custom_language_switcher_links( $languages ) {
    // Add the first external link
    $languages['external_1'] = array(
        'url' => '<em><u>hidden link</u></em>',
        'native_name' => 'Suomi',
        'translated_name' => 'Finnish',
        'country_flag_url' => 'https://cdn.wpml.org/wp-content/plugins/sitepress-multilingual-cms/res/flags/fi.svg',
        'language_code' => 'fi',
        'code' => 'fi'
    );

    // Add a second external link
    $languages['external_2'] = array(
        'url' => '<em><u>hidden link</u></em>',
        'native_name' => 'Latviešu',
        'translated_name' => 'Latvian',
        'country_flag_url' => 'https://cdn.wpml.org/wp-content/plugins/sitepress-multilingual-cms/res/flags/lv.svg',
        'language_code' => 'lv',
        'code' => 'lv'
    );

    // Add a third external link
    $languages['external_3'] = array(
        'url' => '<em><u>hidden link</u></em>',
        'native_name' => 'Lietuvių',
        'translated_name' => 'Lithuanian',
        'country_flag_url' => 'https://cdn.wpml.org/wp-content/plugins/sitepress-multilingual-cms/res/flags/lt.svg',
        'language_code' => 'lt',
        'code' => 'lt'
    );

    return $languages;
}
add_filter( 'icl_ls_languages', 'custom_language_switcher_links' );


**** Important! Please make a full site backup (files and DB) before you proceed with those steps****

Best Regards,
Itamar.

January 29, 2025 at 1:06 pm #16646636

ukuS

Hi
Thanks for the code.
I added it to the page, the flags now appeare but they still don't lead to the links provided. Now I get an error message that nothing appears on this link and the URL is hidden link

Any idea what is wrong?

Thanks

January 29, 2025 at 1:33 pm #16646887

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+02:00)

Hi,

Before sharing the code with you, I tested it, and it worked on my test site.

It looks like some HTML tags got added to your custom code. Please see the attached screenshot. Without seeing your code, I cannot tell what went wrong. I also can't see the problem on your site. The other languages do not show.

If you share with me the code you added to the functions.php file of your theme, I can look to see if I can spot the problem.

Regards,
Itamar.

2025-01-29_15-22-17.jpg
January 29, 2025 at 1:36 pm #16646979

ukuS

Hi
Please see here the screenshot of how I added the code to functions.php file.
I also added a screenshot showing how the flags are now there but the links for LV, LT and FIN don't work.
Thanks

Screenshot 2025-01-29 at 15.34.17.png
Screenshot 2025-01-29 at 15.35.21.png
January 29, 2025 at 5:07 pm #16647952

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+02:00)

Hi,

Thanks for sending the screenshots.

The problem is evident in your screenshot of the code.
The part of the code that is supposed to include the link to your other website is like this:

'url' => '<em><u>hidden%20link</u></em>'

When, for example, it supposes to be like this :

'url' => '<em><u>hidden link</u></em>',

(Each link should be to your other websites.)
You probably copied my code when you were not logged in to your wpml.org account and when you opened the ticket link in the email. In this case, all links are hidden. See how the code looks when you are logged in. Please see the attached screenshot. Compare it to the code on your site or screenshot, and you'll see the mistake.

You must be logged in to your wpml.org account before you copy my code. For your convenience, here is the code again.

function custom_language_switcher_links( $languages ) {
    // Add the first external link
    $languages['external_1'] = array(
        'url' => '<em><u>hidden link</u></em>',
        'native_name' => 'Suomi',
        'translated_name' => 'Finnish',
        'country_flag_url' => 'https://cdn.wpml.org/wp-content/plugins/sitepress-multilingual-cms/res/flags/fi.svg',
        'language_code' => 'fi',
        'code' => 'fi'
    );
 
    // Add a second external link
    $languages['external_2'] = array(
        'url' => '<em><u>hidden link</u></em>',
        'native_name' => 'Latviešu',
        'translated_name' => 'Latvian',
        'country_flag_url' => 'https://cdn.wpml.org/wp-content/plugins/sitepress-multilingual-cms/res/flags/lv.svg',
        'language_code' => 'lv',
        'code' => 'lv'
    );
 
    // Add a third external link
    $languages['external_3'] = array(
        'url' => '<em><u>hidden link</u></em>',
        'native_name' => 'Lietuvių',
        'translated_name' => 'Lithuanian',
        'country_flag_url' => 'https://cdn.wpml.org/wp-content/plugins/sitepress-multilingual-cms/res/flags/lt.svg',
        'language_code' => 'lt',
        'code' => 'lt'
    );
 
    return $languages;
}
add_filter( 'icl_ls_languages', 'custom_language_switcher_links' );

I hope this will help you solve this problem.

Regards,
Itamar.

2025-01-29_18-57-14.jpg
January 29, 2025 at 9:10 pm #16648670

ukuS

Oh yes, stupid me. Thank you, it works perfectly now!