Tagged: external URL, WPML flag
-
AuthorPosts
-
December 16, 2020 at 3:25 pm #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.phpchanged 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,
ArianeDecember 18, 2020 at 11:48 pm #1268514Hey ariane1001,
I did not see the Chinese flag on other pages. Are you hiding it or removed it?
Best regards,
VictoriaDecember 19, 2020 at 2:08 pm #1268617Hi 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,
ArianeDecember 20, 2020 at 5:53 pm #1268809Hi 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,
VictoriaDecember 21, 2020 at 2:19 pm #1269018Hi,
See login in Private content box.
REgards, ArianeDecember 23, 2020 at 9:14 pm #1269627Hi ariane1001,
I cannot see the Appearance editor to check the code, can it be enabled?
Best regards,
VictoriaDecember 24, 2020 at 12:53 pm #1269747Hi 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
December 30, 2020 at 2:54 pm #1269987Hi,
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,
MikeJanuary 4, 2021 at 5:25 pm #1270208Hi 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,
ArianeJanuary 6, 2021 at 2:07 pm #1270615Hi,
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,
MikeJanuary 7, 2021 at 4:12 pm #1270893Hi 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,
ArianeJanuary 9, 2021 at 12:33 pm #1271210Hi,
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,
MikeJanuary 10, 2021 at 2:01 pm #1271355Hi 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,
ArianeJanuary 11, 2021 at 1:14 am #1271402Hi,
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 -
AuthorPosts
- You must be logged in to reply to this topic.