---
title: "Hreflang in WordPress: how plugins print it and how to check"
description: "Where hreflang comes from on WordPress, what WPML, Polylang, TranslatePress and Weglot print by default, how Yoast SEO and Rank Math fit in, and how to check."
url: "https://www.langrelay.com/blog/hreflang-wordpress"
---

1. [Home](https://www.langrelay.com/)
2. [Blog](https://www.langrelay.com/blog)
3. Hreflang in WordPress: how plugins print it and how to check

ArticleMultilingual SEO

# Hreflang in WordPress: how plugins print it and how to check

Where hreflang comes from on WordPress, what WPML, Polylang, TranslatePress and Weglot print by default, how Yoast SEO and Rank Math fit in, and how to check.

[Chris Jayden](https://www.langrelay.com/about)

Founder

Published

6 October 2026

Reading time

7 min read

![Neighbours sit around a fire under green northern lights, on a round bench laid with green and orange leaf tiles.](https://www.langrelay.com/_emdash/api/media/file/01M4ET54EJRHVRKAFWQ7F19SF7.webp)

On this page

1. Who prints what on a multilingual WordPress site
2. What each translation plugin prints by default
3. A correct result, in one example
4. How to check hreflang on a WordPress site
5. Common hreflang mistakes on WordPress
6. How LangRelay does it on WordPress

On a WordPress site, hreflang comes from your translation plugin. WordPress itself runs a site in one language, which it prints as the `lang` attribute, and has no idea that `/fr/rooms/` is the French version of `/rooms/`. WPML, Polylang, TranslatePress, Weglot and LangRelay each add the tags for the languages they manage, with different defaults for x-default and for sitemaps. Yoast SEO and Rank Math look after titles, descriptions, canonicals and the sitemap, and the translation plugin adds hreflang to them. To check the result, open a translated URL's source and compare its hreflang set, canonical and `lang` with the original's.

## Who prints what on a multilingual WordPress site

Three pieces of software write into the `<head>` of a translated page:

| Output | Usually printed by |
| --- | --- |
| `<html lang="...">` | The theme, through WordPress's `language_attributes()`, unless the translation plugin changes it |
| `<title>`, meta description, Open Graph tags | The SEO plugin, or the theme and WordPress core without one |
| `<link rel="canonical">` | The SEO plugin, or WordPress core |
| `<link rel="alternate" hreflang="...">` | The translation plugin |
| Sitemap entries with `xhtml:link` alternates | The translation plugin, inside the SEO plugin's sitemap, where it supports that |

Yoast's help center says Yoast SEO adds canonical URLs to a WordPress site, and that its `wpseo_canonical` filter can change them or remove the tag. On the hreflang side, WPML's documentation for its Yoast SEO and Rank Math integration says the hreflang tags and the language-aware sitemaps come from WPML core, and Rank Math's own knowledge base says WPML adds the hreflang to translated pages. In both cases the SEO plugin owns the canonical and the translation plugin owns the hreflang.

## What each translation plugin prints by default

This is what each vendor's documentation said on 2026-10-06. Where a cell says the documentation does not cover it, check the plugin's output on your own site rather than assuming either way.

| Plugin | Hreflang in the head | x-default | Hreflang in sitemaps | How to adjust |
| --- | --- | --- | --- | --- |
| WPML | One tag per language on every page | Added, for visitors whose language matches no translation | Inside Yoast SEO and Rank Math sitemaps | WPML's settings for URLs, slugs and SEO |
| Polylang | Automatic, in free Polylang too: its hreflang article says it "automatically uses the hreflang HTML tag attributes" | Only on the home page when it is auto-redirected to a language home page | Not covered in the pages checked | The `pll_rel_hreflang_attributes` filter changes the list, for example to add x-default on every page or to replace `en` with `en-GB` |
| TranslatePress | A tag on every page for every language you add | An Advanced setting, "Enable the hreflang x-default tag for language" | With the SEO Pack add-on, which needs a premium version (Personal, Business or Developer), it extends the sitemaps of SEO plugins into a multilingual sitemap | The `trp_hreflang` filter changes the code printed for a language, for example `fr-CH` for the language TranslatePress stores as `fr_FR` |
| Weglot | Added automatically to the `<head>` of your pages | Not added by default | Its WordPress help says the head tags mean you don't need to edit your sitemap by hand; it does not say it writes hreflang into sitemaps | The `weglot_href_lang` filter, for example to add x-default |
| LangRelay | Printed on the original and every translated version | Always the original page's URL | None | The set follows what has been approved and published |

The defaults differ because the vendors read Google's guidance on x-default differently, which the article on [self-referencing hreflang and x-default](https://www.langrelay.com/blog/self-referencing-hreflang-x-default) goes into. If you switch translation plugin, check x-default afterwards: it may change with the plugin without anyone deciding it should.

WPML prints hreflang in the head and inside the sitemaps of Yoast SEO and Rank Math, and its WPML SEO add-on, included with the Multilingual CMS and Agency plans, carries those plugins' fields into translations. Polylang's filter lets a developer reshape the whole list in a few lines of code. TranslatePress puts x-default behind a switch a site owner can set without code. Weglot's WordPress help explains when x-default is worth adding and gives the filter to add it. LangRelay's set needs no configuration, but it has no sitemap output and no way to point x-default anywhere but the original.

## A correct result, in one example

A small hotel's WordPress site is in English, with French and German translations under `/fr/` and `/de/`. This is what the head of the French rooms page should contain once the plugins have done their work, with the lines that matter for hreflang:

```
<html lang="fr">
<head>
  <title>Nos chambres | Orchard Inn</title>
  <link rel="canonical" href="https://www.orchardinn.example/fr/rooms/">
  <link rel="alternate" hreflang="en" href="https://www.orchardinn.example/rooms/">
  <link rel="alternate" hreflang="fr" href="https://www.orchardinn.example/fr/rooms/">
  <link rel="alternate" hreflang="de" href="https://www.orchardinn.example/de/rooms/">
  <link rel="alternate" hreflang="x-default" href="https://www.orchardinn.example/rooms/">
</head>
```

The title is in French, the canonical names the French URL, `lang` says French, and the alternate set is the one that also appears on the English and German rooms pages. Whether x-default is present depends on the plugin, as the table above shows.

## How to check hreflang on a WordPress site

WPML's documentation gives the first step: open a translated URL, view the source, and search for `hreflang`. From a terminal you can see the HTML exactly as your server sends it, before any script runs:

```
curl -s https://www.orchardinn.example/fr/rooms/ \
  | grep -iE 'hreflang|rel="canonical"|<html'
```

Then work through this list, on the original and on one translated page per language:

1. One set only. Each language should appear once. Two `fr` lines usually mean two plugins are printing sets, for example an old translation plugin left active after a switch.
2. The set is identical on every version and includes the page itself. Google asks for both, and ignores a pair that does not point both ways.
3. The codes use a hyphen, not an underscore. WordPress locales are written `fr_FR`; an hreflang value is `fr` or `fr-FR`.
4. The canonical on the translated page names the translated URL. If it names the English page, read [hreflang and canonical tags](https://www.langrelay.com/blog/hreflang-and-canonical-tags) before changing anything.
5. `lang` on the translated page is the translated language. A French page with `lang="en-US"` is a sign the plugin left the theme's value alone; [hreflang vs the HTML lang attribute](https://www.langrelay.com/blog/hreflang-vs-html-lang) explains why that still matters.
6. Every URL in the set answers 200, without a redirect and without `noindex`.
7. If your plugin puts hreflang in the sitemap, open the sitemap and find one translated URL's entry. The article on [hreflang in XML sitemaps](https://www.langrelay.com/blog/hreflang-xml-sitemap) shows what a valid entry looks like.

If you use a page cache, clear it after you change a translation plugin's settings and fetch the page again before you trust what you see.

## Common hreflang mistakes on WordPress

| Mistake | How it shows | Fix |
| --- | --- | --- |
| Two plugins print sets | Duplicate lines per language, sometimes with different URLs | Deactivate the one you no longer use, then check again |
| The SEO plugin's canonical names the original on translated pages | Google may index the original in place of the translation | Let the translation plugin manage the canonical on translated URLs |
| A manual hreflang snippet in the theme | A static set that does not change when a language goes live | Remove it and let the plugin generate the set |
| Untranslated pages listed as translations | A searcher lands on English text under `/fr/` | List a language only once that page is translated; [does machine translation hurt SEO?](https://www.langrelay.com/blog/does-machine-translation-hurt-seo) covers when a translation is ready |
| `lang` still the site language | Screen readers and browsers treat French text as English | Use a plugin that sets `lang` per language |

## How LangRelay does it on WordPress

LangRelay's WordPress plugin translates the rendered page, so `/fr/rooms/` is served from the original rooms post and your posts are not duplicated. That changes where some of the head lines come from, and the plugin handles each of them:

- Hreflang. The plugin prints the set LangRelay sends at `wp_head`, after your title and meta description, without adding or removing entries. The set lists the original, every language in which that page's translation is live, and x-default on the original. The same lines appear on every version.
- Canonical. On a translated page the plugin points the existing canonical tag, whether Yoast SEO, Rank Math or WordPress core printed it, at the translated URL, and does the same for `og:url`. If the page had no canonical, it adds one.
- `lang`. On a translated page the plugin sets `lang` on the `<html>` element to the language's tag. The original keeps the value WordPress prints for the site language.
- Title and meta. The title, meta description and Open Graph and Twitter tags your SEO plugin prints are translated with the rest of the page, and you can edit them in the Visual editor's SEO panel.
- Sitemaps. The plugin leaves them alone. Your SEO plugin's sitemap keeps listing your original URLs, and the translated URLs are linked from the hreflang set, the [language switcher](https://www.langrelay.com/language-switcher) and the internal links on translated pages.

After a release, LangRelay fetches each translated URL and checks its `lang`, its canonical, its own hreflang entry, x-default and `noindex`. A page that contradicts what was published is flagged on the release instead of being reported as delivered. Your Yoast SEO or Rank Math settings stay as they are. Keep a second translation plugin off the pages LangRelay translates, or each page will print two sets.

Our [hreflang guide](https://www.langrelay.com/guides/hreflang) is the hub for this topic, the [multilingual SEO](https://www.langrelay.com/multilingual-seo) page sums up what the plugin covers, and the guide to [translating a WordPress site](https://www.langrelay.com/guides/translate-wordpress-site) walks through the setup. To see the plugin's output on your own site, [book a demo](https://www.langrelay.com/book-a-demo).

## Sources

The pages this one cites, with the day each was read.

1. 01[How to Translate Your Site for Multilingual SEO (WPML documentation, last updated 2026-07-02)](https://wpml.org/documentation/translating-your-contents/multilingual-seo/)wpml.org, checked 6 October 2026
2. 02[WPML SEO: Multilingual Yoast SEO and Rank Math (WPML documentation)](https://wpml.org/documentation/wpml-core-and-add-on-plugins/wpml-seo/)wpml.org, checked 6 October 2026
3. 03[Multilingual SEO with Rank Math SEO and WPML (Rank Math knowledge base)](https://rankmath.com/kb/multilingual-seo-wpml/)rankmath.com, checked 6 October 2026
4. 04[How to change the canonical URL in Yoast SEO for WordPress (Yoast help center)](https://yoast.com/help/canonical-urls-in-yoast-seo/)yoast.com, checked 6 October 2026
5. 05[Features (Polylang)](https://polylang.pro/features/)polylang.pro, checked 6 October 2026
6. 06[Hreflang tag attributes and Polylang: everything you need to know (Polylang, 2023-02-21)](https://polylang.pro/hreflang-tag-attributes-and-polylang-everything-you-need-to-know/)polylang.pro, checked 6 October 2026
7. 07[Filter reference (Polylang documentation)](https://polylang.pro/documentation/support/developers/filter-reference/)polylang.pro, checked 6 October 2026
8. 08[Multilingual SEO (TranslatePress, last updated 2026-03-03)](https://translatepress.com/multilingual-seo/)translatepress.com, checked 6 October 2026
9. 09[SEO Pack (TranslatePress documentation)](https://translatepress.com/docs/addons/seo-pack/)translatepress.com, checked 6 October 2026
10. 10[Advanced Settings (TranslatePress documentation)](https://translatepress.com/docs/settings/advanced-settings/)translatepress.com, checked 6 October 2026
11. 11[Change hreflang localization (TranslatePress documentation)](https://translatepress.com/docs/developers/change-hreflang-localization/)translatepress.com, checked 6 October 2026
12. 12[WordPress: how does Weglot manage the SEO? (Weglot Help Center, last updated 2026-06-29)](https://support.weglot.com/article/99-wordpress-how-weglot-manage-the-seo)support.weglot.com, checked 6 October 2026
13. 13[get\_language\_attributes() (WordPress Developer Resources)](https://developer.wordpress.org/reference/functions/get_language_attributes/)developer.wordpress.org, checked 6 October 2026
14. 14[Localized versions of your pages (Google Search Central, last updated 2026-09-21)](https://developers.google.com/search/docs/specialty/international/localized-versions)developers.google.com, checked 6 October 2026

[Chris Jayden](https://www.langrelay.com/about)

Founder, LangRelay

Chris Jayden is the founder of LangRelay. Chris has worked on websites of every size, from large e-commerce stores to small sites with a handful of pages, and started LangRelay after years of translating them the hard way.

On this page

1. Who prints what on a multilingual WordPress site
2. What each translation plugin prints by default
3. A correct result, in one example
4. How to check hreflang on a WordPress site
5. Common hreflang mistakes on WordPress
6. How LangRelay does it on WordPress

Share

- [Share on LinkedIn (opens in a new tab)](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fwww.langrelay.com%2Fblog%2Fhreflang-wordpress)
- [Share on X (opens in a new tab)](https://x.com/intent/post?url=https%3A%2F%2Fwww.langrelay.com%2Fblog%2Fhreflang-wordpress&amp;text=Hreflang%20in%20WordPress%3A%20how%20plugins%20print%20it%20and%20how%20to%20check)

See it on your site

A 30-minute walkthrough on one of your pages.

[Book a demo](https://www.langrelay.com/book-a-demo)

- hreflang
- multilingual SEO
- WordPress
- yoast SEO

## Keep reading

- Article
  ### [Hreflang in XML sitemaps: syntax, limits and common errors](https://www.langrelay.com/blog/hreflang-xml-sitemap)
  When to put hreflang in a sitemap instead of the page head, one valid multilingual sitemap to copy, Google's size limits and the errors that break the file.
- Article
  ### [Hreflang vs the HTML lang attribute: what each one does](https://www.langrelay.com/blog/hreflang-vs-html-lang)
  The lang attribute says what language this page is in; hreflang points to the page in other languages. Who reads each, valid values, and both in one head.
- Guide
  ### [How to translate a WordPress site: a step-by-step guide](https://www.langrelay.com/guides/translate-wordpress-site)
  Translate a WordPress site from setup to the HTML it serves, covering storage, URLs, hreflang, review and keeping translations current, plus the other routes.

Book a demo

## See LangRelay on your own site

Book 30 minutes with the team. We translate one of your pages live and walk through review, publishing and multilingual SEO.

[Book a demo](https://www.langrelay.com/book-a-demo)[See pricing](https://www.langrelay.com/pricing)
