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: Feature request
This topic contains 6 replies, has 2 voices.
Last updated by Mihai Apetrei 1 year, 8 months ago.
Assisted by: Mihai Apetrei.
Author | Posts |
---|---|
September 14, 2023 at 5:44 am #14393351 | |
charlesc |
We've three versions of the site. All in English, one for intl. users outside EU and US at .../en/, one for EU users at .../eu/ and one for US users at .../us/. I know that en-eu is not a supported hreflang reference for /eu/ version of pages. The correct way to do this would be to include an hreflang reference for each EU country referencing the same /eu/ version of the site. Problem is I don't think WPML supports such an implementation, right? Or is there a way to add all those hreflang references? Hoping this is a situation you've seen and solved before. Thanks Charles |
September 14, 2023 at 10:10 am #14395545 | |
Mihai Apetrei WPML Supporter since 03/2018
Languages: English (English ) Timezone: Europe/Bucharest (GMT+03:00) |
Hi Charles. I wanted to check with my colleagues, first, to make sure that the answer I give here is accurate. This will, indeed, require a good amount of custom work which falls out of the purpose of our Support Policy so I recommend a WPML contractor (https://wpml.org/contractors/) or a developer. The only thing you can do with WPML is to create a custom language for EU and from what I can see, I think you already did that. I have never seen this exact request until now and I was not able to find one in the existing tickets to be able to at least give you something to start with. So this is the best advice that I can give. I hope that you will find it helpful. Mihai Apetrei |
September 15, 2023 at 2:26 am #14400105 | |
charlesc |
Thanks Mihai, We have a dev team so I've put it to them to see if we can develop a solution for this without customizing the plugin. There are many threads with similar questions about hreflang and Europe on Stackexchange so it feels like this may be a feature opportunity. What if on the language edit screen in WPML you could enter an array of hreflang references for each "language". In 99% of cases this will simply be a single hreflang reference as it is today. But in cases such as ours where a custom 'language' was created for a version of the site targeting users in a region, then you could enter an array of hreflang references for all countries in that region and the plugin would inject the appropriate hreflang for each country into the <head> of the page all pointing at the related version of the page. Seems like that would be a fairly simple feature which would require no change to UI, just an update to the input field and an adjustment to the way the plugin injects hreflang into the <head> of each page such that an array resulted in new hreflang references for each country in the array. |
September 18, 2023 at 12:35 pm #14411871 | |
Mihai Apetrei WPML Supporter since 03/2018
Languages: English (English ) Timezone: Europe/Bucharest (GMT+03:00) |
Hi there and thank you for sharing your thoughts. I will share them with my colleagues as a FEATURE REQUEST but we, supporters, have no control over if or when this will be implemented, as the developers team knows better what are the current priorities and urgent matters. Have a lovely rest of the day! Mihai |
September 19, 2023 at 2:36 pm #14420447 | |
Mihai Apetrei WPML Supporter since 03/2018
Languages: English (English ) Timezone: Europe/Bucharest (GMT+03:00) |
Hi there. I'm back. I also reported this to my colleagues in an internal ticket, as I promised. This is the information that I got from them: 1. This is probably not a correct option. You can only specify the regions, not just the country code. See: 2. A regional version of the language is slightly different than the original one and it must be translated so it can be used as a new language. What you mentioned below is not allowed: The correct way to do this would be to include an hreflang reference for each EU country referencing the same /eu/ version of the site. I hope that you will find this information helpful 🙂 Mihai |
September 22, 2023 at 12:41 am #14442793 | |
charlesc |
Yes, I understand that we need to include hreflang references for each EU country pointing to the same /eu/ version of the site. As I understand it however, WPML doesn't allow us to do this. My feature suggestion was an idea to enable this. If I'm wrong and infact there is a way to do this with WPML I would love to know how. |
September 27, 2023 at 8:54 am #14471817 | |
Mihai Apetrei WPML Supporter since 03/2018
Languages: English (English ) Timezone: Europe/Bucharest (GMT+03:00) |
Hi there. I am back - I have updates from our developers in regards to your last reply. They tried the following workaround and it seems to be working fine. Please add this code in functions.php: add_filter('wpml_hreflangs', function( $items ){ // en is the language code that needs duplicate hreflang // en-GB, en-FI.. are the language codes that will be added with en URL. $duplicate_tags = [ 'en' => [ 'en-GB', 'en-FI', 'en-AT', ] ]; foreach ($duplicate_tags as $lang => $langs_to_append) { if (isset($items[$lang])) { foreach($langs_to_append as $lang_code) { $items[$lang_code] = $items[$lang]; } } } return $items; }); You will need to replace the "en" with your actual language code and "en-GB", "en-FI" etc. with the tags you want to add. It will produce the output like this: <link rel="alternate" hreflang="en" href="<em><u>hidden link</u></em>" /> <link rel="alternate" hreflang="hi" href="<em><u>hidden link</u></em>" /> <link rel="alternate" hreflang="es" href="<em><u>hidden link</u></em>" /> <link rel="alternate" hreflang="x-default" href="<em><u>hidden link</u></em>" /> <link rel="alternate" hreflang="en-GB" href="<em><u>hidden link</u></em>" /> <link rel="alternate" hreflang="en-FI" href="<em><u>hidden link</u></em>" /> <link rel="alternate" hreflang="en-AT" href="<em><u>hidden link</u></em>" /> I hope that you will find this helpful. 🙂 Have a lovely rest of the day. Mihai |
September 28, 2023 at 2:53 am #14478103 | |
charlesc |
THanks very much. Appreciate the follow through. |