[Waiting for user feedback] Translated URLs in content are incorrect
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.
Our wait time is higher than usual, please make sure you are meeting the minimum requirement - https://wpml.org/home/minimum-requirements before you report issues, and if you can take a look at current Known Issues - https://wpml.org/known-issues/. Thank you.
Background of the issue:
I am trying to add Spanish translations to an existing English site and created the Spanish pages using the English content as a base (by copying content from the English page onto the Spanish, then adding the translated text). As a result the English URLs are still in the Spanish content. WPML seems to be trying to update the English URLs on the frontend without us doing anything, but that does not seem to always work. Additionally, the "Scan now and adjust links" button on the Settings page says that it made changes to 0 links (or does nothing). Link to a page where the issue can be seen: hidden link
Symptoms:
For URLs with a depth of 1 (like hidden link), only the first depth 1 URL on the page is translated correctly. All further depth 1 URLs are given the same translated URL as the first depth 1 URL on the page. URLs with a depth greater than 1 (like hidden link) are translated correctly.
Questions:
How can I ensure all English URLs are correctly translated to Spanish URLs?
The site is currently up and should be accessible.
The provided guide says nothing about "custom links". We have seen that guide, and it says "There is a known issue with translating internal links inside buttons, calls to actions, and other similar blocks. While we fix this, please ask our support for help."
This is only for internal links on the website. External links should remain the same, and that is the behavior we are seeing. The "Adjust Links Feature" does nothing.
And yes, we can go through and manually adjust the pages to have the correct urls in the content. However the automatic pointing of internal links is broken and cannot seem to be turned off, and so until we can go in and manually update all of the urls across the approximately 131 pages, all of those pages have incorrect links.
I will need to closely examine your website. Therefore, I will require temporary access (WP-Admin and FTP) to a test site where the problem has been replicated, if possible. This will enable me to provide better assistance and determine if any configurations need to be modified.
Please note that it is important to have a backup for security purposes and to prevent any potential data loss. You can use the UpdraftPlus plugin (https://wordpress.org/plugins/updraftplus/) to fulfill your backup requirements.
Your upcoming reply will be treated with confidentiality and will only be visible to you and me.
✙ To resolve the issue, I may need your consent to deactivate and reactivate plugins and the theme, as well as make configuration changes on the site if necessary. This emphasizes the significance of having a backup.
Thanks for your reply. You can clone the site to another staging site and then remove all sensitive data from the site so that I can check this out for you. Please let me know how it goes.
This is not possible from our end at this time. There is not client approval to spend time on creating another copy of the site.
We can offer a screen share, or can provide our current setup instructions for how we've configured WPML.
Isn't there a known issue with translating internal links inside buttons, calls to actions, and other similar blocks? Is there something from that that we can explore?
Thanks for your reply. I've prepared a sandbox site here hidden link and could you please replicate the issue over there so that I can check what's going on? You can install the required plugins and themes.
Thank you for setting up that sandbox site. We have replicated the base issue there turning on only the WPML plugin and no others. You can see the page demonstrating the issue here: hidden link
We've tried to document the links and their status on the page in a fairly clear manner but some more details:
On the page you'll see that some links are getting converted automatically to the correct translated page, but others are not. Specifically the 1st link on the page gets correctly converted from its English page to the Spanish equivalent. However, all of the rest of the links to existing English pages are being changed to be the same as the first link on the page as opposed to their correctly translated pages. Whatever link is put first gets correctly converted but then all other converted links inherit that conversion instead of their correct one.
Links to non-existent (404) pages on the site are correctly unchanged, as are direct links to Spanish versions of pages.
We dove into the guts of WPML and the issue appears to be ultimate related to `get_matching_page_displayed_as_translated()` in the `WPML_Name_Query_Filter_Translated` class. This class appears to store an array of `$this->pages_to_langs` which builds up with each URL in the content to be converted. However the logic there returns the first match on the first URL in that array instead of the correct one.
I also wanted to add that (after saving permalinks) this is only impacting depth 1 links. Links with a depth greater than 1 are also correctly converted to their translated equivalent. You can see this in the two depth 2 examples provided on the sandbox site page.
Kor, thank you for escalating this to Tier 2. Please let us know if we can provide anything else that may be useful. We are hoping to launch our translated site in the next week or two, but do need to get this bug resolved so that we don't have to try to go through all of the pages and manually update hundreds of links.
We did try the "scan links and update them" button in the WPML settings, but that did not change any links.
Kor, Is there any update on the timing for review and/or resolution of this bug? We are at the stage of having everything completed for our translated site except for this issue. Obviously this is a fairly significant blocker to deploying though as numerous links are incorrect on almost every page of the site.