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 4 replies, has 2 voices.
Last updated by Shekhar Bhandari 1 year, 5 months ago.
Assisted by: Shekhar Bhandari.
Author | Posts |
---|---|
September 13, 2023 at 12:39 pm #14390263 | |
witoldR |
Tell us what you are trying to do? I'm wondering if WPML generates the hreflang automatically for WooCommerce product variation. Is there any documentation that you are following? Is there a similar example that we can see? What is the link to your site? |
September 13, 2023 at 12:41 pm #14390275 | |
witoldR |
Could you include, include desar.***@***.nl in the support ticket so that I (Desar) get the notification when the ticket is updated? Thank you. Best regards, Desar, |
September 18, 2023 at 5:14 am #14409061 | |
Shekhar Bhandari Supporter
Languages: English (English ) Timezone: Asia/Kathmandu (GMT+05:45) |
Hello there, Welcome to WPML support, I'd be happy to help you on this. I'm wondering if WPML generates the hreflang automatically for WooCommerce product variation. I don't think hreflang is generated for WooCommmerce product variation automatically, but since you mentioned that you have added a code to generate it, possibly it's generating due to that code. Can you remove the code and see if the hreflangs are generated? Also, can you provide us the code that you are using? Further, We recently released a new version of WPML plugins so can you please update the plugins to the latest version and let me know if that helps. We push out WPML releases gradually. If your sites haven’t received this update yet, give it some time and you’ll see the update in a few days. To skip the queue and get the update right away, to the Plugins → Add New page, click the Commercial tab and then click the Check for updates button. Note: Keep a Backup Before Updating It's impossible to add email notifications on the forum ticket, so I suggest checking the forum ticket itself for new messages. Look forward to your reply. Thanks |
September 19, 2023 at 2:25 pm #14420353 | |
witoldR |
Hi there, The website uses a normal page as a placeholder to display the product variation. This is the code that is being used to 'fix' this hreflang function translate_uri($uri) { if ($uriBits[1] == 'en') { switch ($uriBits[4]) { return "/$uriBits[2]/$uriBits[3]/$uriBits[4]/"; switch ($uriBits[3]) { return "/en/$uriBits[1]/$uriBits[2]/$uriBits[3]"; function fix_hreflangs($hreflang_items) { foreach ($hreflang_items as $key => $url) { return $hreflang_items; return $hreflang_items; add_filter('wpml_hreflangs', 'fix_hreflangs', 20); Is there a way to get the id of the translated variation? Looking forward to hearing from you soon. Best regards, Desar, |
September 20, 2023 at 7:01 am #14426669 | |
Shekhar Bhandari Supporter
Languages: English (English ) Timezone: Asia/Kathmandu (GMT+05:45) |
Hello there, As the screenshot shows, the hreflangs aren't showing for product variation and only showing for the product, so it's the code. Further, Is there a way to get the ID of the translated variation? You can use these hooks, https://wpml.org/wpml-hook/wpml_object_id/ Look forward to your reply. Thanks |
September 26, 2023 at 9:39 am #14465463 | |
witoldR |
Thanks Shekhar, function fix_hreflangs($hreflang_items) { foreach ($hreflang_items as $key => $url) { $hreflang_items = array( return $hreflang_items; return $hreflang_items; add_filter('wpml_hreflangs', 'fix_hreflangs', 20); |