This thread is resolved. Here is a description of the problem and solution.
Problem:
The client is experiencing incorrect hreflang attributes for custom post types (CPTs) on their multilingual website. The English and x-default URLs are not displaying correctly when checked in Italian, despite being fine in English. Solution:
We recommend downgrading to the stable release of WPML if you're encountering similar hreflang issues with custom post types. Specifically, the client was advised to install WPML 4.6.9 stable release instead of the beta version they were using. You can download the latest stable versions from the My Account -> Downloads section of the WPML website.
Please note that this solution might not apply to your situation if it's outdated or not relevant to your case. If the problem persists after trying the suggested steps, we highly recommend checking the related known issues, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If you still need assistance, please don't hesitate to open a new support ticket. For further help, you can reach out to us on the WPML support forum.
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.
Hello, I am noticing issues with hreflang for this website.
I have several CPTs added via code, translated with WPML. If I check the hreflangs in English they are fine; if I check them in Italian this is the result:
The english and x-default link should be hidden link
This happens for every CPT, with or without Yoast SEO active, after saving permalinks and posts too.
I am trying to:
have hreflangs properly displayed to help SEO and multilanguage content
Link to a page where the issue can be seen: hidden link
I expected to see:
Can you please provide details on how you created your custom post type (CPT)? You can share a code. Have you tried disabling all plugins except WPML plgins to see if the issue persists?
Additionally, could you share screenshots of the custom post and its translations?
It's important to backup your database before making any changes.
Please bear in mind that this happens also on other CPTs on the same website, but not to pages and posts as far as I can see.
I tried to toggle "has_archive" on true/false as another user here said it solved its issue, but without results.
I disabled other plugins without results, even after saving permalinks again.
Thank you again,
Luigi
Thank you for your feedback, Luigi. I appreciate it. Can you please provide screenshots of how you created and translated those custom posts? What are results with any default theme?
To help further diagnose the problem, I suggest downloading our Toolset Types plugin from your account: https://wpml.org/account/downloads/. Once you have downloaded and installed the plugin, you can create a test custom post type and custom posts under it. This will help us determine if the issue is related to your code or if there is a general problem with custom post types in your installation.
Please backup your database before making any changes.
Hello Andrey, I created a CPT via Tooset Types plugin and the result is the same, even after refreshing permalinks and changing the theme to Twenty Twenty One.
Here is the URL in English, where hreflangs are correct: hidden link
This is the URL in Italian: hidden link
In Italian hreflangs are incorrect:
<link rel="alternate" hreflang="en" href="hidden link" />
<link rel="alternate" hreflang="it" href="hidden link" />
<link rel="alternate" hreflang="x-default" href="hidden link" />
Please find attached some screenshots (I don't know what could be helpful to debug this issue).
Thank you for providing your tests and feedback. I find it strange that I am unable to replicate the issue you are facing. However, I noticed that you are using WPML beta 4.6.10-b.1 plugin. Can you please try installing WPML 4.6.9 stable release and check if the issue still persists?
You can find the latest released versions under "My Account -> Downloads" on this website. Please let me know how it goes.