Skip to content Skip to sidebar

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:

register_post_type('event', [<br />  'public' => true,<br />  'has_archive' => true,<br />  'rewrite' => [<br />    'slug' => 'company/events',<br />    'with_front' => false,<br />  ],<br />]);

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.

Tagged: 

This topic contains 8 replies, has 0 voices.

Last updated by desireeH-2 2 months, 4 weeks ago.

Assisted by: Bobby.

Author Posts
February 3, 2026 at 5:20 pm #17789185

desireeH-2

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?

February 4, 2026 at 7:29 am #17790037

Bobby
WPML Supporter since 04/2015

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Hi there,

Before we look into more complex possibilities, please test the following and let me know the results:

Go to WPML → Settings and verify that the CPT is set to Translatable.

Verify that at least one item exists per language.

My suspicion is that these translations may be stand-alone rather than connected.

When reviewing them in the backend, do they show as connected translations?

February 4, 2026 at 2:58 pm #17792648

desireeH-2

Hi Bobby,

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?

Please let me know.

Thanks!

February 4, 2026 at 9:58 pm #17794047

Bobby
WPML Supporter since 04/2015

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

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.

Thank you,
Bobby

February 5, 2026 at 8:03 pm #17797695

Bobby
WPML Supporter since 04/2015

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Thank you for the access details!

When reviewing the archive template directly via this link
hidden link

we can see that it's fully translated and works as expected.

Secondary language example:
hidden link

If you go to Pages -> search for events -> — Events | Parent Page: Company page is currently not translated to the rest of the languages.

Please send the page for translation and let me now your results.

February 6, 2026 at 2:47 pm #17800110

desireeH-2

Hi Bobby,

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.

Thanks!

February 7, 2026 at 1:13 am #17801548

Bobby
WPML Supporter since 04/2015

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Thank you, that makes sense.

If possible, please share with me the CPT registration code.

There might be a possible issue with the CPT registration causing the language switcher to not be able to map the tranlsations.

When transaltions are directly accessed they work, therefore there is an issue with the way they are being mapped.

For example:

Your CPT should be registered like this:

register_post_type('event', [
'public' => true,
'has_archive' => true,
'rewrite' => [
'slug' => 'company/events',
'with_front' => false,
],
]);

not like this:

'has_archive' => 'company/events'

February 7, 2026 at 1:39 am #17801560

Bobby
WPML Supporter since 04/2015

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Following up on this:

The CPT is created with ACF therefore please dismiss my previous recommendation (even though true 🙂 if anybody else is dealing with this.)

Go to ACF->Post Types-> Events-> URLs -> Archive Slug -> it's recommended practice to clear it and leave empty.

This did not resolve it, which then turned me to test with minimal environment, it looks like the Child Theme is causing this behavior.

Switching to a default theme (Twenty25 or Elementor parent) resolves the issue.

I will get back with more updates shortly.

February 7, 2026 at 2:26 am #17801568

Bobby
WPML Supporter since 04/2015

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

The issue is coming from this piece of code in the child theme's functions.php

// Modifies the events query to only show upcoming or ongoing events
function modify_events_query($query) {
    $today = date('Y-m-d');

    $meta_query = [
        'relation' => 'OR',
        [
            'relation' => 'AND', // This includes single-day events that are upcoming, or happening today
            [
                'key' => 'start_date',
                'value' => $today,
                'compare' => '>=',
                'type' => 'DATE'
            ],
            [
                'key' => 'is_multi_day_event',
                'value' => '0',
                'compare' => '='
            ]
        ],
        [
            'relation' => 'AND', // This includes multi-date events are are upcoming or ongoing
            [
                'key' => 'is_multi_day_event',
                'value' => '1',
                'compare' => '=',
            ],
            [
                'key' => 'end_date',
                'value' => $today,
                'compare' => '>=',
                'type' => 'DATE'
            ],
        ]
    ];

    $query->set('meta_query', $meta_query);
    $query->set('orderby', 'meta_value');
    $query->set('meta_key', 'start_date');
    $query->set('order', 'ASC');
}

function modify_events_archive_query($query) {
    if (!is_admin() && $query->is_main_query() && is_post_type_archive('event')) {
        modify_events_query($query);
    }
}
add_action('pre_get_posts', 'modify_events_archive_query');
February 9, 2026 at 4:13 pm #17806252

desireeH-2

Thank you for the assistant! The function just needed to not run before WPML generates the hreflangs.