Plugins Plugin hub Backup SEO Caching Security Forms WooCommerce Images Best backup plugins
Hosting Hosting directory Shared hosting Managed WordPress Cloud hosting VPS hosting By reader location Hosting finder
Themes & builders Compare Rank Math vs Yoast
Tools All tools Hosting finder Plugin stack builder Cost calculator Salt generator Theme detector Who is hosting this? Speed test Headline analyzer robots.txt generator Redirect generator Uptime calculator Blog name generator
Blog Best backup plugins Deals
Guides All guides Speed up WordPress Choose hosting Back up WordPress
How we test

Plugin how-tos · Guide

How to Add Polylang Language Switcher in Header (Step by Step)

How to Add Polylang Language Switcher in Header (Step by Step)

Short answer

In a classic theme, open Appearance, then Menus, enable the Language switcher box, add it to your header menu and save. In a block theme, open the header in the Site Editor and insert Polylang's language switcher block inside the Navigation block.

Key takeaways

  • Classic themes use the Language switcher box in Appearance > Menus.
  • Block themes use Polylang's switcher block inside the header Navigation block.
  • Enable the box under Screen Options if it is hidden.
  • Add the switcher to each language's header menu.
  • Developers can use pll_the_languages() in a child theme.

How do you add the Polylang language switcher to your header?

In a classic theme, add the Language switcher item to your header menu under Appearance > Menus; in a block theme, add Polylang's language switcher block to the header's Navigation block.

Which route you take depends on your theme, not on Polylang. Classic themes use the old Menus screen. Block themes, such as Twenty Twenty-Four and newer, build headers in the Site Editor.

There are two more options for special cases. A header widget area can hold the Language switcher widget, and developers can print the switcher in a template with a PHP function.

The Polylang language switcher documentation lists every display option. This guide walks through each method step by step.

Your setupMethodWhere
Classic theme with a header menuLanguage switcher menu itemAppearance > Menus
Block themeLanguage switcher block in NavigationAppearance > Editor
Theme with a header widget areaLanguage switcher widgetAppearance > Widgets
Elementor headerThird-party switcher widget or shortcodeElementor editor
Custom or child themepll_the_languages() functionheader template

What do you need before you start?

You need Polylang installed and active, at least two languages added, and some content translated so the switcher has somewhere to send visitors.

If you have not set up languages yet, go to Languages > Languages and add them first. Our guide on how to use the Polylang plugin covers that setup.

The switcher links to the translation of the current page. If a page has no translation, Polylang links to the home page of the other language, or hides that language if you tell it to.

Take a quick backup before editing headers, especially in the Site Editor, where changes apply across the whole site.

Step 1: Find out whether your theme is classic or block-based

Open Appearance in the dashboard; if you see Editor, you have a block theme, and if you see Menus and Customize, you have a classic theme.

This matters because block themes hide the old Menus screen. Polylang's menu-based switcher only shows up in Appearance > Menus.

Some hybrid themes show both. In that case, check where your header is actually built. If the header uses a menu location, the classic method works.

Our guide on editing the header in a block theme explains the Site Editor layout if it is new to you.

Step 2 (classic themes): Add the Language switcher to your menu

Go to Appearance > Menus, pick the menu assigned to your header, open the Language switcher box on the left, tick it and click Add to Menu.

If you cannot see the Language switcher box, click Screen Options at the top right of the screen and tick Language switcher. It is hidden by default on some sites.

Step by step:

  1. Go to Appearance > Menus.
  2. Choose the header menu from Select a menu to edit.
  3. Open Screen Options and enable Language switcher if needed.
  4. Tick Languages in the Language switcher box.
  5. Click Add to Menu.
  6. Drag the new item to where you want it, often the far right.
  7. Click Save Menu.

Make sure the menu is assigned to your theme's header or primary location under Menu Settings. If it is not assigned, nothing will show on the site.

With Polylang, each language often has its own menu. Add the switcher to every language's header menu, or visitors will lose it after switching.

Step 3 (classic themes): Choose how the switcher looks

Click the arrow on the Language switcher menu item to open its options, tick the ones you want and save the menu.

The common options are:

  • Displays as dropdown: shows one item that opens a list of languages.
  • Displays language names: shows names like English or Français.
  • Displays flags: shows a small flag next to or instead of the name.
  • Forces link to front page: always sends visitors to the home page.
  • Hides the current language: removes the language the visitor is already on.
  • Hides languages with no translation: skips languages missing a translation.

For headers, a short dropdown or flags plus short names usually fit best. Long language names can push other menu items onto a second line on smaller screens.

Accessibility tip: flags represent countries, not languages, so showing names alongside flags helps visitors.

A visible switcher matters because guessing a language from the browser is not always right. The W3C article on language negotiation explains why visitors should be able to change language themselves.

Step 4 (block themes): Add the switcher block to your header

Go to Appearance > Editor, open the header template part, select the Navigation block, click the plus icon inside it, search for Language switcher and insert it.

Here is the full path:

  1. Go to Appearance > Editor.
  2. Open Patterns or Template Parts and choose Header.
  3. Click the Navigation block in the header.
  4. Click the + inside the Navigation block.
  5. Search for Language switcher and add it.
  6. Set the display options in the block sidebar.
  7. Click Save.

Polylang adds a dedicated language switcher block for this. Inside a Navigation block it behaves like a menu item, so it follows your header's font and spacing.

The block settings mirror the menu options: dropdown, names, flags, hide current language and so on. Changes apply to every page that uses this header.

The WordPress documentation for the Navigation block explains how menus are built in block themes.

How do you add the switcher with a widget instead?

If your theme has a widget area in the header, go to Appearance > Widgets, add the Language switcher widget to that area and save.

Many classic themes only have sidebar and footer widget areas. Check the list of areas first. If there is no header area, use the menu method instead.

The widget has the same display options as the menu item. It also includes a title field, which you can leave empty so only the switcher shows.

How do you add the switcher to an Elementor header?

Polylang does not ship an Elementor widget, so use a third-party connector plugin that adds one, or place the switcher inside a WordPress menu and show that menu in Elementor's Nav Menu widget.

The menu route is the simplest. Add the Language switcher to a WordPress menu as in Step 2, then pick that menu in Elementor's Nav Menu widget in your header template.

Several free connector plugins on WordPress.org add a dedicated Polylang switcher widget to Elementor. Check that any connector is actively maintained before you rely on it.

Our guide on whether Polylang works with Elementor covers the wider compatibility picture.

How do developers add the switcher in PHP?

Call pll_the_languages() in your child theme's header template, passing arguments for dropdown, names and flags, and wrap it in a list element.

A simple example looks like this:

<ul class="lang-switcher">
  <?php if ( function_exists( 'pll_the_languages' ) ) {
    pll_the_languages( array( 'show_flags' => 1, 'show_names' => 1, 'hide_if_empty' => 0 ) );
  } ?>
</ul>

The function_exists check stops the site from breaking if Polylang is ever deactivated. Without it, a missing function causes a fatal error.

Always edit a child theme, not the parent. Theme updates overwrite parent theme files. The Theme Handbook on child themes explains the setup.

Polylang's developer details are listed on its WordPress.org plugin page and in the documentation linked above.

How do you style the switcher in the header?

Use your theme's menu styles first, then add a little custom CSS under Appearance > Customize > Additional CSS or in the Site Editor's styles if you need to tweak spacing or flag size.

Most of the time, the switcher inherits your menu fonts and colors automatically. Problems usually come down to flag images sitting too high or a dropdown clashing with the header background.

A few small tweaks that often help:

  • Add a left margin so the switcher sits apart from other links.
  • Align flags vertically with the text.
  • Hide language names on mobile and keep flags only.
  • Give the dropdown a solid background so it stays readable.

Test the header on a phone. Mobile menus often collapse the switcher into the hamburger menu, which is fine as long as it stays easy to find.

Why is the switcher not showing in the header?

The usual causes are a menu not assigned to the header location, the switcher added to only one language's menu, caching, or the hide options removing every language.

Run through these checks:

  1. Confirm the menu is assigned to the header location in Menu Settings.
  2. Add the switcher to the header menu of each language.
  3. Untick Hides languages with no translation to test.
  4. Clear caching plugins, host cache and CDN cache.
  5. Check that your theme does not hide extra menu items on mobile.

If it still does not appear, see our dedicated guide on Polylang language switcher not working, which covers more fixes in detail.

For caching problems in particular, our guide on how to clear cache in WordPress walks through each layer.

Frequently asked questions

Why can't I see the Language switcher box in Appearance Menus?

It is often hidden. Click Screen Options at the top right of the Menus screen and tick Language switcher. If the Menus screen itself is missing, you are using a block theme and should use the switcher block in the Site Editor.

Does the Polylang switcher work with block themes?

Yes. Polylang provides a language switcher block that you can place inside the Navigation block of your header template part. It offers the same display options as the classic menu item, such as dropdown, names and flags.

Should I show flags or language names in the switcher?

Language names are clearer, since flags stand for countries rather than languages. Many sites show both, or use short names with flags. On small screens, a dropdown keeps the header tidy.

Why does the switcher disappear after I change language?

Each language usually has its own menu in Polylang. If you added the switcher only to the menu for one language, it vanishes when visitors switch. Add it to the header menu for every language.

Is there a Polylang shortcode for the language switcher?

The core plugin does not provide a shortcode. Use the menu item, block or widget instead, or call the pll_the_languages function in a child theme template. Some third-party add-ons provide shortcodes if you need one.

Sources

  1. The language switcher Polylang
  2. Polylang plugin WordPress.org
  3. Navigation block WordPress.org Documentation
  4. Child themes WordPress Developer Resources
  5. Language negotiation W3C

Is your product missing, or something out of date?

Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.

About the editors

Written and checked byWPLegible Editorial Team Independent WordPress reviews and guides

Researched from the primary sources listed above and checked against our editorial rules before publishing.