Skip to content Skip to sidebar

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.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 17:00 10:00 – 17:00 10:00 – 17:00 10:00 – 17:00 10:00 – 17:00 -
- 18:00 – 19:00 18:00 – 19:00 18:00 – 19:00 18:00 – 19:00 18:00 – 19:00 -

Supporter timezone: Asia/Kathmandu (GMT+05:45)

This topic contains 3 replies, has 1 voice.

Last updated by Shekhar Bhandari 1 month, 1 week ago.

Assisted by: Shekhar Bhandari.

Author Posts
March 10, 2026 at 11:33 am #17885003

izoH

Good day,

We use WPML for two different languages and different domain names. The issue is that in the, not main, language version of the site the hreflang's are incorrect.

Looking at the source of "view-source:hidden link", the conical links are perfect:

The nl-be version is pointing the the correct URL on staging2.boekdrukken.be. Looking at the page on boekdrukken.be though the links to the nl-nl are incorrect, it seems like the domain name of the nl-nl site is not used:

We've already cleared/disabled caching and this gave no resolution to the problem. Could you please assist fixing this issue?

Thanks.

March 10, 2026 at 4:03 pm #17886243

Nigel
WPML Supporter since 02/2016

Timezone: Europe/Madrid (GMT+02:00)

Hi there

Before this is taken by a colleague, let me share some thoughts after reading the advice given to you by Maiya.

Maiya correctly identified that the problem likely relates to your settings in wp-config.php for the WP_HOME and WP_SITEURL constants, but looks to have misidentified whether you were using a WordPress multisite installation or not.

Let me clarify.

According to what I read, you are using a single site which is set to use different domains per language.

I'm not sure which is your default site and which the secondary language site.

Let's assume that the .nl site is your default, and the .be site is the secondary language.

In which case the .nl url is the "real" site, and the .be url is a virtual url that points to the .nl server, where the WordPress files and database actually reside.

So, there is only one wp-config.php file.

For WPML to work correctly, if you want to define the WP_HOME and WP_SITEURL constants, they should be defined with static values (not with a variable like $_SERVER['HTTP_HOST']).

And the static value should always point to the default language site url (which I have assumed to be the .nl url), e.g.

define( 'WP_HOME', '<em><u>hidden link</u></em>' );
define( 'WP_SITEURL', '<em><u>hidden link</u></em>' );

I suspect you had defined them to use $_SERVER['HTTP_HOST'] because your workflow means that you have the same wp-config.php file on staging and on production.

In that case you would need to conditionally set the constants depending on whether you were in the staging environment or production environment. Sometimes people define this with a constant within the config file so that it needs changing in only one place. Another option could be to check whether whether the current url is a staging environment or not, and set the constants accordingly (always to static strings themselves), e.g.

if (strpos($_SERVER['HTTP_HOST'], 'staging') !== false) {
    define('WP_HOME', '<em><u>hidden link</u></em>' );
    define('WP_SITEURL', '<em><u>hidden link</u></em>' );
} else {
    define('WP_HOME', '<em><u>hidden link</u></em>');
    define('WP_SITEURL', '<em><u>hidden link</u></em>');
}

You would need to modify that if your default language site is actually the .be site.

Do you want to try that and see if it resolves the problem?

March 12, 2026 at 1:52 pm #17892528

izoH

Hi,

Thank you for your response.

We are using a multisite installation indeed. At this stage we're building and testing the staging-version(s) only. I've changed the wp-config.php to have the following code to make sure the site correctly identifies the domain:

if ( $_SERVER['HTTP_HOST'] == 'staging2.boekdrukken.be' ) {
define('WP_HOME','hidden link');
define('WP_SITEURL','hidden link');
} elseif ( $_SERVER['HTTP_HOST'] == 'staging2.probook.nl' ) {
define('WP_HOME','hidden link');
define('WP_SITEURL','hidden link');
} else if ( $_SERVER['HTTP_HOST'] == 'www.probook.nl' ) {
define('WP_HOME','hidden link');
define('WP_SITEURL','hidden link');
} else if ( $_SERVER['HTTP_HOST'] == 'www.boekdrukken.be' ) {
define('WP_HOME','hidden link');
define('WP_SITEURL','hidden link');
} else {
define('WP_HOME','hidden link' . $_SERVER['HTTP_HOST']);
define('WP_SITEURL','hidden link' . $_SERVER['HTTP_HOST']);
}

Our primary version of the site is staging2.probook.nl and secondairy version is staging2.boekdrukken.be. I've checked the WP_HOME and WP_SITEURL after the change above and I do get the right values:

[12-Mar-2026 13:49:21 UTC] WP_HOME: hidden link
[12-Mar-2026 13:49:21 UTC] WP_SITEURL: hidden link

I'm affraid this did not solve the issue, I still get this on staging2.boekdrukken.be:
<link rel="alternate" hreflang="nl-be" href="hidden link" />
<link rel="alternate" hreflang="nl-nl" href="hidden link" />
<link rel="alternate" hreflang="x-default" href="hidden link" />

While staging2.probook.nl shows:
<link rel="alternate" hreflang="nl-be" href="hidden link" />
<link rel="alternate" hreflang="nl-nl" href="hidden link" />
<link rel="alternate" hreflang="x-default" href="hidden link" />

So it still seems that staging2.boekdrukken.be is not using the URL of the primairy site in the alternate links.

Any suggestions?

Thank you!

March 13, 2026 at 3:16 am #17894183

Shekhar Bhandari
WPML Supporter since 03/2015

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

To debug this issue further, I would need to check your site settings once, for this I would need temporary access (wp-admin and ftp) to your site.

So could you please provide me with those details, you will find the needed fields for this below the comment area when you log in to leave your next reply.
hidden link

This info is private and available to you and WPML supporters only.
Read more about this: https://wpml.org/purchase/support-policy/privacy-and-security-when-providing-debug-information-for-support/

Note:
Backup your sites before providing the credentials or if possible provide credentials for the test site

Look forward to your reply.

Thanks

The topic ‘[Closed] Alternate links incorrect on translated version of the site’ is closed to new replies.