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.

This topic contains 2 replies, has 2 voices.

Last updated by sergeyS-14 2 years, 3 months ago.

Assigned support staff: David.

Author Posts
June 11, 2018 at 1:59 pm #2405260

sergeyS-14

I have custom taxonomys 'city' and 'property-type' for custom post type 'property'
'city' = hidden link
'property-type' = hidden link

So ive Added new rewrites to my custom taxonomy 'city' and mix it with 'property-type'

and now my url is
hidden link
in explanation is:
hidden link taxonomy slug)/(property-type taxonomy slug)/

But the links in Language Switcher is wrong

Link to a page where the issue can be seen:

I expected to see(in Language Switcher): hidden link

Instead, I got: hidden link

I believe i need to change some how the url in Language Switcher in the top of thw website.

**So as i can understand the link came to the language switcher because the last query was for this taxonomy (property-type in my case), so how i can prevent this or override to get my own links instead of latest taxonomy links?

Or even better, just let me know where is code in your plugin responsible for this behavior and i will see and understand how i can make this works for me.

Thank you.

June 12, 2018 at 5:45 pm #2409213

David
Supporter

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

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

    WPML exposes a filter called 'icl_ls_languages'. You can use it to customize the url in the language switcher.

    function wpml_url_fix( $languages ) {
    
      // make your changes to the $languages array here.
     
      return $languages;
    }
    add_filter( 'icl_ls_languages', 'wpml_url_fix');
    

    The array you will receive looks like this:

    Array
    (
    [en] => Array
    (
    [id] => 1
    [active] => 1
    [native_name] => English
    [missing] => 0
    [translated_name] => English
    [language_code] => en
    [country_flag_url] => hidden link
    [url] => hidden link
    )

    [fr] => Array
    (
    [id] => 4
    [active] => 0
    [native_name] => Français
    [missing] => 0
    [translated_name] => French
    [language_code] => fr
    [country_flag_url] => hidden link
    [url] => hidden link
    )

    [it] => Array
    (
    [id] => 27
    [active] => 0
    [native_name] => Italiano
    [missing] => 0
    [translated_name] => Italian
    [language_code] => it
    [country_flag_url] => hidden link
    [url] => hidden link
    )
    )

    June 13, 2018 at 2:29 pm #2411395

    sergeyS-14

    Thank you, i will use this filter!