
Table of Contents
- Answer first: what to do and how to know it is correct
- Preparation Process: baseline, staging and rollback point
- Step 1: directory prefix vs subdomain
- Step 2: what must be translated
- Step 3: hreflang and sitemaps
- Step 4: language switcher UX
- Validation Step: go-live gate and monitoring
- Rollback Step: restore cleanly without losing content
- Frequently asked questions
- Action checklist
Answer first: what to do and how to know it is correct
Use Polylang Pro 3.7.x or current 2026 stable on WordPress 6.8+ with PHP 8.2+, choose directory prefixes such as /en/ and /fr/ unless you have a hard DNS or cookie reason for subdomains, translate every indexable and user-visible string, then verify that each language URL returns 200, has one self-referencing hreflang, reciprocal alternates, canonical to itself, and appears only in the correct XML sitemap. A correct Polylang multilingual setup means editors can create paired content, the switcher never sends users to a 404, search engines see a clean one-language-per-URL signal, and you can restore the pre-launch database and rewrite rules in under 30 minutes.
Preparation Process: baseline, staging and rollback point
- Clone production to staging, freeze content edits, and record versions:
wp core version,wp plugin list --format=csv, PHP version, active theme, and Polylang version. - Take a database and file snapshot with
wp db export backup/pre-polylang-2026.sqlandtar -czf backup/wp-content-pre-polylang-2026.tgz wp-content. - Confirm permalinks are not Plain, HTTPS is enforced, and the site has one canonical host in
wp-config.phpor server config. - Install Polylang Pro, WooCommerce multilingual add-ons if needed, and a SEO plugin known to output sitemaps; keep object cache off during first sync.
- Create a language map: default language, locale, URL slug, editor owner, and whether each post type and taxonomy is translatable.
- Write down the rollback trigger: any 404 spike, mixed-language sitemap, duplicate
hreflang, or checkout translation break.
Before changing URLs, read the official Polylang plugin documentation and the WordPress developer APIs handbook if you plan custom code. If the project also includes a host or domain migration, align DNS and redirect work with WordPress Domain Replacement: Vendor Evaluation Guide 2026 before language URLs are generated, because changing both at once makes logs ambiguous.
Set a repeatable CLI baseline
Run these commands from the WordPress root on staging. They give you a before-state and a quick smoke test after every step.
wp core version
wp plugin list --status=active --format=table
wp option get home
wp option get siteurl
wp option get permalink_structure
mkdir -p backup
wp db export backup/pre-polylang-2026.sql
tar -czf backup/wp-content-pre-polylang-2026.tgz wp-content
curl -sSIL https://staging.example.com/ | sed -n '1,12p'Store the output in the deployment ticket. In 2026, Polylang Pro 3.7.x is the practical baseline for agencies because it includes language-by-domain, duplicate content control, REST/API improvements and better integration with block themes; verify the exact installed version with wp plugin get polylang-pro --field=version rather than assuming the number. Keep WordPress core, SEO plugin and cache plugin updated on staging first, then promote the same versions together.
Step 1: directory prefix vs subdomain
Default to directory prefixes. In Polylang, go to Languages → Settings → URL modifications, set The language is set from the directory name, and use slugs such as en, fr, de. The default language can either keep /en/ or hide its prefix depending on Polylang settings; pick one and never change it after indexing. Directory prefixes keep one TLS certificate, one cookie scope, one CDN cache key strategy, one analytics property and simpler internal linking. They also make rollback a rewrite-rule change rather than a DNS propagation event.
Configure directory prefixes
Use this checklist in the admin UI: add languages with exact WordPress locales, for example English / en_US, Français / fr_FR, Deutsch / de_DE; set the default language; enable Hide URL language information for default language only if the home page must remain /; save once; then run Settings → Permalinks → Save Changes or wp rewrite flush --hard. On Nginx, make sure the WordPress front-controller pattern is used, not a static try_files rule that strips /fr/.
# Nginx site config, WordPress 6.8+ / Polylang directory mode
location / {
try_files $uri $uri/ /index.php?$args;
}
# Do NOT add a separate /fr/ root block; Polylang resolves the prefix.
# After saving languages:
wp rewrite flush --hard
curl -sSI https://staging.example.com/fr/ | grep -Ei 'HTTP/|location|x-redirect'Expected result: /fr/ returns 200 or a controlled 301 to the translated front page, never 404 and never a loop. Check wp option get polylang or the Polylang settings export before and after; do not hand-edit serialized options unless you are restoring the exact snapshot.
When subdomains are justified
Use subdomains only when legal entities, separate CDN contracts, separate consent/cookie domains, or an existing global DNS design require fr.example.com. In Polylang Pro choose The language is set from the subdomain name or domain mapping, create DNS CNAME or A records with a short TTL before launch, issue a wildcard or SAN certificate, and set home/siteurl consistently. Cross-domain analytics, login cookies, WooCommerce session cookies and CORS for REST calls all need explicit tests. If you are already reviewing infrastructure vendors, coordinate this with Domain Configuration for WordPress: 2026 Vendor Guide so wildcard DNS and certificate ownership are assigned before launch.
Common pitfalls and rollback
Common failures: a CDN rule caching / and serving English to /fr/; a redirect plugin forcing the bare domain; hardcoded home_url() links in a page builder; /en/ added twice after permalink flush; or subdomain cookies scoped to .example.com leaking admin language. Rollback for directory mode: restore the saved Polylang settings to one language, run wp rewrite flush --hard, purge CDN and object cache, then replay backup/pre-polylang-2026.sql if language terms were assigned. Rollback for subdomain mode also means removing DNS records and any domain-mapping rows, so keep TTL low for 48 hours before launch.
Get a Quote
Email + requirement + budget range — we reply with a quote within 24 hours.
Step 2: what must be translated
Translate anything that can be indexed, clicked, read by a customer, used in a transaction, or emitted in structured data. Polylang stores language as the taxonomy language and translation relationships in the term_relationships-driven translation groups; your job is to decide coverage, not to translate every private draft. As a rule, translate public post types, pages, custom post types, categories, tags, custom taxonomies, menus, widgets/blocks, media metadata, SEO titles and descriptions, slugs, form labels, email templates, WooCommerce product attributes, checkout notices, cookie/consent copy, 404 and search templates, and JSON-LD strings generated by the theme.
Build the translation matrix
Create a table in the deployment ticket and tick every row before launch. Use Polylang Languages → Settings → Custom post types and Taxonomies to enable translation only for rows marked yes; leaving a public CPT untranslated is the most common source of mixed-language archives.
| Object | Translate | Where in Polylang / code | Verification |
|---|---|---|---|
| Posts, pages, public CPTs | Yes | Languages → Settings → Custom post types; post editor language box | Each post has one translation per active language and a self canonical |
| Categories, tags, custom taxonomies | Yes | Term language + translations screen | /fr/category/slug-fr/ returns French archive, not English terms |
| Menus, widgets, block patterns | Yes | Appearance → Menus language assignments; pll_the_languages() for switcher | Switcher on every template points to an existing translated object |
| Media title, alt text, caption | Yes | Media language and translation metabox | wp_get_attachment_image() outputs localized alt |
| Theme and plugin strings | Yes | load_theme_textdomain(), pll_register_string(), Languages → Strings translations | wp i18n make-pot finds no untranslated UI string in templates |
| SEO meta, Open Graph, JSON-LD | Yes | SEO plugin per-language fields; filter schema output | View-source on each language contains matching og:locale and localized name |
| WooCommerce emails, checkout, account | Yes | WooCommerce Polylang integration + string translations | Test order in each locale; email and thank-you page match order language |
| Private drafts, revisions, internal notes | No | Leave unassigned or default language | Not present in sitemap or public switcher |
Register theme strings instead of hardcoding them
Use WordPress i18n for theme code and pll_register_string() only for editor-managed strings stored in options. The snippet below is safe to place in a child theme functions.php or a small mu-plugin at wp-content/mu-plugins/ml-strings.php. It guards against Polylang being deactivated during rollback.
<?php
/**
* Plugin Name: Site Multilingual Strings
* Requires PHP: 8.2
* Tested up to: 6.8
*/
add_action( 'init', function () {
load_theme_textdomain( 'runok', get_stylesheet_directory() . '/languages' );
if ( ! function_exists( 'pll_register_string' ) ) {
return;
}
pll_register_string( 'runok_cta', 'Request a quote', 'Site UI', true );
pll_register_string( 'runok_cookie_notice', 'We use cookies.', 'Site UI', true );
} );
add_filter( 'runok_cta_label', function ( $label ) {
return function_exists( 'pll__' ) ? pll__( 'Request a quote' ) : $label;
} );
// Generate POT on staging before editors translate:
// wp i18n make-pot wp-content/themes/child-theme wp-content/themes/child-theme/languages/runok.potVerify with wp i18n make-pot, then open Languages → Strings translations and confirm the group Site UI appears for every locale. For block themes, also inspect theme.json and reusable blocks; block markup can contain literal English labels that no POT scan will catch. If custom templates query content directly, review Direct Queries with $wpdb: When to Use Them and How to Stay Safe before adding WP_Query language filters, because raw SQL that ignores the language taxonomy will silently mix locales.
Assign languages in bulk, then audit
On an existing site, Polylang offers Languages → Bulk translate or the Set language bulk action for legacy content. Run it on staging first. Use WP-CLI to find public content still missing a language term:
wp post list --post_type=post,page,product --post_status=publish --format=count
wp term list language --format=table
wp db query "SELECT p.ID, p.post_type FROM wp_posts p
WHERE p.post_status = 'publish'
AND p.post_type IN ('post','page','product')
AND NOT EXISTS (
SELECT 1 FROM wp_term_relationships tr
JOIN wp_term_taxonomy tt ON tt.term_taxonomy_id = tr.term_taxonomy_id
WHERE tr.object_id = p.ID AND tt.taxonomy = 'language'
) LIMIT 50;"Expected result after assignment: zero rows. Then use wp post list --post_status=publish --format=csv --fields=ID,post_title,url and spot-check paired URLs. Pitfalls include translating the slug but not the term, duplicating media instead of translating metadata, leaving English alt text on French pages, and enabling translation on a CPT whose rewrite base is shared. Rollback: disable CPT/taxonomy translation in settings, delete only the newly created translation posts by ID from your export log, and restore the language terms from backup/pre-polylang-2026.sql on staging before repeating.
Step 3: hreflang and sitemaps
Let one component own hreflang. In a 2026 stack, Polylang Pro outputs <link rel="alternate" hreflang="..." href="..." /> in wp_head and Yoast SEO or Rank Math outputs language-aware sitemaps; do not also hand-code alternates in header.php or inject them in a CDN worker. Every URL must include a self-referencing alternate, all siblings must be reciprocal, and x-default should point to the language selector or the agreed default landing URL. Canonical must remain the same-language URL, never the default English page.
Inspect the head, not just the admin screen
Run this for every representative URL: home, a post, a category, a product, and a paginated archive. The script below is intentionally simple and works on staging or production.
for u in
https://staging.example.com/
https://staging.example.com/fr/
https://staging.example.com/fr/blog/
https://staging.example.com/de/produkt/example/ ; do
echo "=== $u"
curl -sSL "$u" | grep -Eio '<link[^>]+(alternate|canonical)[^>]*>' | sort
done
curl -sS https://staging.example.com/sitemap_index.xml | grep -Eo 'https?://[^<]+.xml'
curl -sS https://staging.example.com/fr/sitemap_index.xml | head -40
wp rewrite flush --hardExpected result: en_US appears as en or en-US consistently, fr and de appear on all three paired pages, each set contains the current URL, and no 404 URL is listed. If your SEO plugin emits hreflang too, disable one source. Polylang has a pll_rel_hreflang_attributes filter for edge cases; use it only to normalize a locale code, not to add missing translations.
Sitemap rules that prevent bad indexing
Keep one sitemap index, include only 200 canonical URLs, exclude noindex drafts, search results, /wp-admin/, feed URLs and redirect chains, and make sure each language sitemap is reachable from the index. With Yoast SEO, confirm SEO → General → Features → XML sitemaps is on and inspect /sitemap_index.xml, /post-sitemap.xml, /fr/post-sitemap.xml equivalents generated by the integration. With Rank Math, inspect /sitemap_index.xml and the language modules. Purge the sitemap cache after adding a language; on WP Rocket or a CDN, purge both page cache and sitemap cache. Submit only the index in Search Console, not every language file.
Common pitfalls and rollback
Common failures: x-default pointing to a redirected URL; hreflang using en_US instead of a valid BCP 47 tag; canonical collapsed to the default language by a SEO template; a multilingual sitemap containing untranslated posts; or a security plugin stripping <link> tags. Verify with curl -sSL as an anonymous visitor and again with cache-cookie headers cleared. Rollback: disable the SEO plugin sitemap module or the Polylang hreflang output, not both; restore the previous header.php from backup/wp-content-pre-polylang-2026.tgz; purge cache; re-run the head grep until exactly one complete reciprocal set remains. If URLs were already indexed, keep temporary 301 redirects from any retired prefix instead of deleting them.
Step 4: language switcher UX
The switcher is navigation, not decoration. Place it in the header, keep it in the footer or mobile drawer, use the language’s own name, show the current language clearly, and link to the equivalent translated object. If no translation exists, either hide that option or send the user to the translated home page with an explicit notice; never silently drop them on an English article after they clicked Français. Add hreflang and lang attributes to the switcher links for assistive technology, and keep the control outside cached fragments that vary by user but not by language.
Implement a deterministic switcher
Use Polylang’s pll_the_languages() in a template part such as wp-content/themes/child-theme/parts/language-switcher.php. The options below avoid flags-only UI, hide empty translations, and force the current language to render so the control has a stable width.
<?php
if ( function_exists( 'pll_the_languages' ) ) {
$languages = pll_the_languages( array(
'echo' => 0,
'hide_empty' => 1,
'show_flags' => 0,
'show_names' => 1,
'display_names_as' => 'name',
'force_home' => 0,
'current_lang' => 1,
'raw' => 0,
) );
echo '<nav class="lang-switcher" aria-label="' . esc_attr__( 'Language', 'runok' ) . '">';
echo '<ul>' . $languages . '</ul>';
echo '</nav>';
}
// CSS: .lang-switcher .lang-item-current a { font-weight: 700; }
// Cache test: curl -sSL https://staging.example.com/fr/blog/ | grep -o 'lang-switcher[^>]*'For a block theme, register the template part in theme.json or render it through a small block that calls the same function. For WooCommerce, test cart, checkout, My Account and order-received pages; the switcher must preserve the cart and not reset the session. If the switcher is built in a page builder, compare its links against pll_get_post() output; hardcoded links are the number-one cause of 404s after a slug change.
Verify UX and accessibility
Test with keyboard only, a screen reader label, mobile viewport at 360px, and a browser with cookies disabled. Click each language on home, single post, archive, 404 and search results. Expected result: the URL changes prefix or host, <html lang="fr-FR"> changes, the menu changes, the canonical changes, and the switcher still shows the active item. Add a small automated check to the release ticket:
for u in / /fr/ /de/ /fr/blog/ /de/blog/ ; do
printf '%s ' "$u"
curl -sSL "https://staging.example.com$u"
| grep -Eio '<html[^>]*lang=["'"'"'][^"'"'"']+' | head -1
done
wp cache flush
curl -sSI https://staging.example.com/fr/ | grep -Ei 'HTTP/|cache-control|vary'Pitfalls: flags used as the only label, display_names_as='slug' producing FR instead of Français, a cached header fragment built before Polylang set the language, Vary missing on a CDN that caches by path only, and hide_empty=1 leaving a single-item control with no explanation. Rollback: replace the template part with the previous static header from the tarball, call wp cache flush, purge CDN, and re-enable the Polylang menu item only after the head and sitemap checks pass. For deeper template work, our Custom WordPress Development team usually keeps the switcher in version-controlled theme code rather than in a database-managed builder so it can be reverted with a single deploy.
Validation Step: go-live gate and monitoring

Run the full gate on staging, then repeat the read-only checks on production immediately after deploy. Do not launch if any row fails. Keep the checks in docs/multilingual-gate-2026.md so the next upgrade uses the same evidence.
| Check | Command or location | Pass condition |
|---|---|---|
| Status codes | curl -sSIL on home, post, term, product per language | 200 or one intentional 301; zero 404 and zero loops |
| Language assignment | wp term list language plus the missing-language SQL above | Zero published public posts without a language term |
| Head signals | curl grep for alternate and canonical | One self alternate, reciprocal set, same-language canonical |
| Sitemaps | /sitemap_index.xml and each language child sitemap | Only 200 canonical URLs; no redirects or untranslated drafts |
| Switcher | Header, footer, mobile drawer, WooCommerce checkout | Equivalent object, active state, correct html lang |
| Cache | Anonymous curl with and without cookies; CDN purge log | No English body served on /fr/; Vary or path key is correct |
| Rollback drill | Restore SQL + tarball on a disposable clone | Single-language site loads in under 30 minutes |
After launch, watch 404 logs, Search Console coverage, sitemap fetch errors and conversion funnels per language for 14 days. In 2026, also sample server logs for bots requesting retired URL shapes; add 301 redirects rather than letting a multilingual plugin guess. If you change the default-language prefix later, treat it as a migration project, not a settings toggle, and review Change a WordPress Domain Without Losing SEO or Sales for redirect mapping discipline. For broader release patterns, see the technical column index.
Rollback Step: restore cleanly without losing content
Rollback is a rehearsed sequence, not a panic edit. First switch the site to maintenance mode and stop editors. Export the current multilingual database anyway, because it contains any new orders or comments created after launch; then restore structure, not blindly overwrite live transactions. On a staging clone, import backup/pre-polylang-2026.sql, extract backup/wp-content-pre-polylang-2026.tgz, deactivate Polylang Pro with wp plugin deactivate polylang-pro, run wp rewrite flush --hard, and purge all caches. If only URL mode is wrong, keep content and change URL modifications back to one language plus a single permalink flush; this is faster and preserves translations for a second attempt.
# Disposable rollback drill, never run directly on live production
wp maintenance-mode activate
wp db export backup/post-launch-forensics-2026.sql
wp db import backup/pre-polylang-2026.sql
wp plugin deactivate polylang-pro
wp rewrite flush --hard
wp cache flush
wp maintenance-mode deactivate
curl -sSI https://rollback.example.com/ | grep -Ei 'HTTP/|location'
# Merge new WooCommerce orders/comments from the forensics export before any real restore.For subdomain rollback, remove DNS records after lowering TTL, revoke the extra certificate only after traffic stops, and clear any domain-mapping option. For CDN rollback, purge by prefix /fr/*, /de/* and invalidate the sitemap paths. Document the exact cause: duplicate hreflang, cache key, CPT coverage, or switcher links. Re-run the validation gate before attempting launch again; do not re-enable languages one by one in production while bots are crawling.
Frequently asked questions
Should I use directory prefixes or subdomains for a new Polylang multilingual setup?
Use directory prefixes in almost every new build. They simplify TLS, cookies, analytics, CDN keys and rollback. Choose subdomains only for legal, contractual or cookie-isolation requirements, and test DNS, certificate and session behavior before launch.
Can I rely on automatic translation for SEO meta and WooCommerce emails?
No. Machine translation is acceptable as an editor draft, but a human must approve slugs, SEO titles, structured data, checkout strings and transactional emails. Verify rendered HTML and a real test order in each locale before go-live.
What breaks hreflang most often after a Polylang update?
Duplicate output from both Polylang and a SEO plugin, canonical templates forced to the default language, and cached headers generated before the language was resolved. Grep anonymous HTML after every update and keep exactly one owner for alternates.
Action checklist
- Snapshot database and
wp-content, record WordPress 6.8+, PHP 8.2+ and Polylang Pro versions, and rehearse rollback on a clone. - Lock directory prefixes, add locales, flush rewrites, and confirm every language URL returns 200 with the correct
html lang. - Complete the translation matrix, register theme strings, assign languages to all published content, and audit with SQL.
- Validate one reciprocal
hreflangset, same-language canonicals, clean sitemaps, and a switcher that links equivalent objects. - Monitor 404s, coverage and conversions per language for 14 days, and keep the gate document for the next upgrade.
Need a reviewed multilingual deployment? Our engineers handle Polylang architecture, theme i18n, hreflang audits and safe rollback for production WordPress sites. See all services or send your staging URL for a technical review.
