Home›Support›English Support›[Resolved] CPT archive hreflang tags pointing to homepage instead of translated archives
[Resolved] CPT archive hreflang tags pointing to homepage instead of translated archives
This thread is resolved. Here is a description of the problem and solution.
Problem: You are experiencing an issue where hreflang tags on custom post type (CPT) archives for 'event' are incorrectly pointing to the homepages instead of the translated archive pages. This issue is causing 'missing reciprocal hreflang' errors in SEO audits.
Solution: First, ensure that your CPT 'event' is set to 'Translatable' in WPML settings and that translations for the archives are properly connected. If the issue persists, the problem might be related to the theme or specific customizations in your theme's functions.php file. Here are the steps we recommend: 1. Verify the CPT registration settings. It should look like this:
2. If you are using a child theme or have custom functions that modify the query, ensure they are not affecting the hreflang output. For example, check if modifications in the functions.php like custom query filters are interfering. 3. Test with a default theme (e.g., Twenty Twenty-Five or Elementor parent) to see if the issue resolves, indicating a theme-specific problem. 4. If these steps do not resolve the issue, it might be due to limitations in the ACF or WPML integration or a need for manual adjustments in the theme or plugin settings.
This solution might be outdated or not applicable to your specific case. If the problem persists, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If necessary, please open a new support ticket at WPML support forum for further assistance.
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.
I'm experiencing an issue with hreflang tags on custom post type archives not generating correctly.
The problem:
I have a CPT called "event" with slug /company/events/
The archive exists in all languages (e.g., /it/company/events/, /de/company/events/, etc.)
However, the hreflang tags on the English archive page point to the homepages instead of the translated archives
What I see in the page source of /company/events/:
What it SHOULD show:
My setup:
WPML Multilingual CMS (latest version)
WPML SEO (latest version)
Yoast SEO
CPT is set to "Translatable" in WPML settings
The translated archives ARE accessible and work correctly when visited directly
Regular pages and posts have correct hreflang tags - only CPT archives are affected
This is causing "missing reciprocal hreflang" errors in SEO audits. How can I fix the hreflang generation for CPT archives?
I can confirm that the CPT is set to "Translatable." I'm not sure I fully understand your other question. These CPTs are like events, right now, there are no active events, but there are past events and all of them have translations.
Regardless, the problem is with the archive page, not the posts themselves. I don't use single pages for the archives; I use Elementor templates, and yes, the translations are properly connected. Does this answer your question?
Thank you, yes that answers it, I would like to request temporary access (wp-admin and FTP) to your site to test the issue.
(preferably to a test site where the problem has been replicated if possible)
**Before we proceed It is necessary to take FULL BACKUP of your database and your website. Providing us with access, you agree that a backup has been taken **
I often use the Duplicator plugin for this purpose: http://wordpress.org/plugins/duplicator/
You will find the needed fields for this below the comment area when you log in to leave your next reply.
The information you enter is private which means only you and I have access to it.
NOTE: If access to the live site is not possible and the staging site does not exist please provide me with a duplicator package created with the duplicator plugin.
Oh okay, there's a little confusion here. One of our attempts to fix this issue was creating an Events page and translating it; in production, we don't actually have a page for Events. Since this attempt didn't work and the translated versions not only failed to fix the issue but also didn't load the template properly, that page shouldn't be there. It was just a test to try to solve the problem.
If you need more information or context about this, please let me know.