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.

Our next available supporter will start replying to tickets in about 2.76 hours from now. Thank you for your understanding.

Tagged: 

This topic contains 17 replies, has 2 voices.

Last updated by Santiago 11 months, 3 weeks ago.

Assisted by: Dražen Duvnjak.

Author Posts
May 7, 2023 at 2:00 am #13599577

Santiago

Hello there,
Looks like the next code can be a better solution to avoid the errors.
Basically using the language of the current page for language_code and code.
Does that make sense to you?
Thank you again.-

function custom_language_switcher_links( $languages ) {

    $languages['external'] = array(
        'url' => '<em><u>hidden link</u></em>',
        'native_name' => 'International site',
        'translated_name' => 'International site',
        'country_flag_url' => 'https://cdn.wpml.org/wp-content/uploads/flags/flag-global.svg',
        'language_code' => ICL_LANGUAGE_CODE,
        'code' => ICL_LANGUAGE_CODE
    );
    return $languages;
}
add_filter( 'icl_ls_languages', 'custom_language_switcher_links' );
May 8, 2023 at 7:02 am #13602169

Dražen Duvnjak
Supporter

Languages: English (English )

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

Hello,

thanks for getting back.

At first sight looks okay, if you can make it open in a new tab then I think it should be fine. I also advise testing further to make sure it functions fine on other pages also.

Regards,
Drazen

May 9, 2023 at 3:36 pm #13615401

Santiago

Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.