Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #1267852

    Hi,
    I used this solution: https://kriesi.at/support/topic/wpml-link-one-flag-to-different-domain/#post-1093670 with the code from https://github.com/KriesiMedia/enfold-library/blob/master/actions%20and%20filters/WPML/avf_wpml_language_switcher_url.php

    changed it to

    /**
     * Filter the URL in language switcher flags
     * 
     * @since 4.5.6.1
     * @param string $url
     * @param string $lang_code
     * @param string $menu_position				'sub_menu' | 'main_menu'
     * @return string
     */
    function my_wpml_language_switcher_url( $url, $lang_code, $menu_position )
    {
    	if( $lang_code == 'zh-hans' )
    	{
    		$url = 'https://innovationquarter.cn';
    	}
    	
    	return $url;
    }
    
    add_filter( 'avf_wpml_language_switcher_url', 'my_wpml_language_switcher_url', 10, 3 );

    It works fine on the homepage https://innovationquarter-ontw.nl/iq/ but not on other pages in de the website.
    Can this be fixed?

    Thanks in advance,
    Ariane

    #1268514

    Hey ariane1001,

    I did not see the Chinese flag on other pages. Are you hiding it or removed it?

    Best regards,
    Victoria

    #1268617

    Hi Victoria,
    Maybe you clicked a link to the live website: https://www.innovationquarter.nl, in the menu are one or two hard links to that site.

    Because the flag is definitely on other pages like: https://innovationquarter-ontw.nl/iq/ons-team/, https://innovationquarter-ontw.nl/iq/maritiem-haven/, https://innovationquarter-ontw.nl/iq/contact-2/
    and everywhere it is pointing to https://innovationquarter-ontw.nl/iq/zh-hans/ instead of to the external url https://innovationquarter.cn (except for the homepage, there it works)

    Hope you can have another look and not put me on the end of the list again….

    Best regards,
    Ariane

    #1268809

    Hi ariane1001,

    Can you give us temporary admin access to your website in the private content box below, so that we can have a closer look?

    Best regards,
    Victoria

    #1269018

    Hi,
    See login in Private content box.
    REgards, Ariane

    #1269627

    Hi ariane1001,

    I cannot see the Appearance editor to check the code, can it be enabled?

    Best regards,
    Victoria

    #1269747

    Hi Victoria,
    As I mentioned before, it’s a multisite so you will find the appearence editor of the theme in the menu Network Admin > themes > Theme editor and the theme used here is IQ, You can select the right menu in the right upper corner ‘Select theme to edit:’
    The code is in functions.php starting ad line 172.

    Thank you in advance, I hope you can help now.

    Regards, Ariane

    #1269987

    Hi,
    Sorry for the very late reply and thanks for the login, I tried investigating why the [CH] language switcher is not linking correctly on other pages, when I check your functions.php it looks like you have created a custom post type of “iq” and a custom category of “iq”, from past experience I have seen strange issue arise when a post type and category type are the same.
    I also have a question about the function “wpmlcore_3937_fix_for_enfold_page_builder” and what it is doing with “_aviaLayoutBuilderCleanData”
    I’m not sure what might be causing this, but I’m thinking it could be a conflict in functions.

    Best regards,
    Mike

    #1270208

    Hi Mike,
    On this first working day of the year I wish you a happy and healthy 2021!

    On your note about the custom post type of “iq” and a custom category of “iq”, I don’t know what you mean. Or is it the ‘iq’ after parts of the function to make a custom post type? That’s not the name, only for WPML to see in which part (the theme iq) the translation belongs to. It’s there for at least 3 years now and working well.

    On you note about the conflict in functions, I removed the other WPML / Avia functions but no difference.
    The functions are there because there where problems with avia and WPML before…. Hopefully they are not needed anymore.

    Hope you have any other idears to get the link on the chinese flag good.
    Regards,
    Ariane

    #1270615

    Hi,
    Thank you, I also wish you a happy and healthy 2021🙂
    As I investigated further I noted that in WPML > Language URL format > A different domain per language it says: This option is not yet available for Multisite installs
    so I understand that you are trying to work around this with the function above, but since it is not working on all pages I wonder if WPML is working against us by setting the URL after Enfold, or some other conflict.
    At the current setting WPML > Language URL format > Different languages in directories you can see that the “expected” URL is the undesiered /iq/zh-hans/
    I found that this option in WPML can be turned on, so perhaps using this instead will work correctly.
    I found the link to the WPML function from this WPML support thread, I’m linking to it because it has further tips than the official page that might help you.

    Best regards,
    Mike

    #1270893

    Hi Mike,
    Thanks for the effort you’ve made, but this solution doesn’t work. I need only 1 language to go to an external url. I’ve tried it but all languages will co to something/iq/ since thats the url of the directory the site in. And thats not working.
    So the Chinese site will go to https://innovationquarter.cn/iq/ instead of https://innovationquarter.cn/

    I solved it now like this:
    1. the code in the functions.php so from the homepage you will go directly to https://innovationquarter.cn/.
    2. made a redirect from /iq/zh-hans/ to https://innovationquarter.cn/.

    To my surprise it works, so I leave it with this and am going to put it on the live site, fingers crossed it will go well there too.
    Thanks again for your help.

    Best regards,
    Ariane

    #1271210

    Hi,
    Thank you for the feedback and glad to hear that you were able to sort this out.
    Unless there is anything else we can assist with on this issue, shall we close this then?

    Best regards,
    Mike

    #1271355

    Hi Mike,
    I believe the problem still exists, although I have a solution. But Closing the issue is fine because I don’t thing better solution will pop-up any time soon.
    Thanks and regards,
    Ariane

    #1271402

    Hi,
    Very good, I believe that the WPML > Language URL format > A different domain per language might still be helpful even though you only need one external link, because you could set the other “external” link to your current URL, but it is basically doing the same redirect that you achieved otherwise, so going through all the steps to enable the option for your Multisite may not worth it.
    If you are still interested, I was working on another “language” function today and I noted that the function used this to check the language:
    if (get_locale() == 'zh-CN') {
    instead of
    if( $lang_code == 'zh-hans' ) {
    Perhaps this would be worth a try.

    Best regards,
    Mike

Viewing 14 posts - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.