Language switcher options for WordPress
WP Provider Translate gives your visitors a language switcher as soon as you add a language: a small floating switcher at the bottom of the screen. You can also place the switcher yourself, as a block, a shortcode, a menu item or an Elementor widget, and choose whether it shows flags, language names or codes. Each switcher can be a dropdown or a list. If you like, a small banner can also suggest the visitor’s own language.
The floating language switcher
Out of the box, a dropdown switcher sits at the bottom right of every page. It is there so visitors can always change language, even before you decide where a switcher belongs on your site.
- It steps aside by itself. The floating switcher only shows when no other switcher is on the page. Once you add one to your menu, header or footer, the floating one disappears.
- Move it or switch it off under WP Provider Translate → Settings → Languages → Language picker: choose Bottom right or Bottom left, or untick Show a floating picker when no other picker is on the page. Click Save Changes.
- It works without JavaScript. The dropdown is built into the browser, so it keeps working with script optimisers and caching plugins, and it is left out when someone prints the page.
Flags, names or codes
Under WP Provider Translate → Settings → Languages → Language picker you choose how every switcher shows a language, unless a switcher sets its own:
- Show flags. Tick it to show a small flag before each language.
- Full name (Nederlands), Code (NL) or Flag only. Language names are always written in their own language (Deutsch, Français), so visitors recognise their own.
Which flag a language gets:
- Your site’s own language gets the flag of the country in your WordPress site language, when it has one. A site in English (United States) shows the US flag, a site in Dutch (Belgium) the Belgian flag.
- Other languages get the flag most people expect, such as the British flag for English and the Brazilian flag for Portuguese (Brasil).
With Flag only, the language name is still there for screen readers.
Language switcher block
On a block theme, or anywhere you build with blocks, use the Language picker block.
- Open the page, template or template part (for example your header) in the block editor or the Site Editor.
- Add a block and search for Language picker.
- In the block settings on the right, under Display, choose:
- Style: Dropdown, Horizontal or Vertical.
- Flags: As in the settings, Show or Hide.
- Text: As in the settings, Language name, Language code or None (flag only).
- Hide the current language: list only the other languages.
- Use the block toolbar to align it left, centre or right, and save.
Language switcher shortcode
Anywhere that accepts shortcodes (a classic widget, a text block, a page builder’s shortcode element), add:
[wpprovider_language_picker]That gives a dropdown with the settings from WP Provider Translate → Settings. Add options to change it:
| Option | Values | What it does |
|---|---|---|
style | dropdown, inline, vertical | A dropdown, a horizontal list or a vertical list |
flags | yes, no | Show or hide flags |
name | name, code, none | Language name, code, or no text (flag only) |
hide_current | yes | Leave the current language out |
For example, a row of flags without text for the footer:
[wpprovider_language_picker style="inline" flags="yes" name="none"]A switcher left by your previous translation plugin
If you switched from another translation plugin, its language switcher shortcode may still be in your theme or your content. For the switcher shortcodes of several translation plugins, including TranslatePress, WP Provider Translate shows its own switcher in that place once the other plugin is deactivated, with the style from your settings, so you don’t have to edit your pages first. While the other plugin is still active, its switcher is left to it. For TranslatePress, see what comes over from TranslatePress.
Replace an old switcher with [wpprovider_language_picker] or the Language picker block when you next edit the page, so it keeps working if you remove the old plugin’s data later.
Dropdown, horizontal or vertical list
The block, the shortcode and the Elementor widget all offer the same three styles:
- Dropdown. Shows the current language; a click opens the others. Takes the least space, good for headers.
- Horizontal. All languages side by side, good for a footer or a top bar.
- Vertical. All languages underneath each other, good for a sidebar or a mobile menu.
With Hide the current language, a site with two languages shows a single link to the other one.
Elementor language switcher widget
If you build with Elementor, use the Language picker widget.
- Edit the page or your header template with Elementor.
- Search the widgets for Language picker (or “language”, “switcher”) and drag it in.
- On the Content tab, set Layout (Dropdown, Horizontal or Vertical), Flags, Text, Hide the current language and Alignment.
- On the Style tab, match it to your design: typography, Text color, Hover color, Current language color and Flag width. A dropdown also has Dropdown background, Dropdown hover background and Dropdown border color; a list has Space between languages.
- Click Publish or Update.
Suggest the visitor’s language
A visitor whose browser is set to German lands on your English page. With Suggest the visitor’s language turned on, a small banner in the bottom corner tells them: “This page is also available in Deutsch”, with a link to that version. The visitor decides; nobody is redirected.
- Go to WP Provider Translate → Settings → Languages.
- Under Visitor’s language, tick Suggest the visitor’s language. It is off until you turn it on.
- Click Save Changes.
How it works:
- It follows the browser’s languages. Visitors set their preferred languages in their browser, in order. The banner suggests the first of those the page exists in: the exact language first, then the same language without its region (a browser set to German (Austria) is offered German), then a regional version of it (a browser set to Portuguese is offered Portuguese (Brazil)).
- Only when it helps. No banner when the visitor already reads the page in that language, when the page doesn’t exist in the visitor’s language, or when the page has an address with a question mark in it (such as a filtered shop page). Error pages and search results don’t show it either.
- The language name is in its own language, so visitors recognise it: Deutsch, Français, Nederlands.
- It stays out of the way. The banner sits in the bottom corner away from the floating switcher and doesn’t move your layout. The cross or the Escape key closes it.
- The browser remembers. Once a visitor closes the banner, it stays away. A language they pick with any switcher, menu link or the banner itself replaces what their browser says, so the banner never argues with their choice. With a domain per language, each domain remembers this on its own.
- Search engines are not affected. The page is the same for every visitor and for search engines; the banner is added in the visitor’s browser, so it works with caching plugins and never hides a language from a search engine. Search engines and other robots don’t get the banner.
Language switcher in the menu
To put the switcher in your menu bar like any other menu link, see Language switcher in the menu.
Good to know
- The order of the languages is the order of your list under Translate into. See Choose your languages.
- Only languages the page exists in are offered. A page that is not available in a language yet, or that you keep out of a language, leaves that language out of the switcher on that page. See How translation runs.
- The switcher itself is never translated. Language names stay in their own language on every page.
- Every link in the switcher points to the same page in the other language, not to the home page, so visitors keep their place.
- With a domain per language, the switcher links to the other domain and takes the shopping cart along. See A domain per language.
Troubleshooting
- There are two switchers on my page. The floating one hides when your own switcher is built into the page before it. A switcher that a script or popup adds after the page has loaded is not seen in time. Untick Show a floating picker when no other picker is on the page in that case.
- The switcher doesn’t show at all. It needs at least one language under Translate into. If you use a caching plugin, clear its cache after changing switcher settings. See Caching plugins.
- The language banner doesn’t show. Check that Suggest the visitor’s language is ticked and that the page exists in a language your browser prefers over the one you are reading. If you closed the banner once, or picked a language with the switcher, your browser remembers that: try a private window. Clear your caching plugin’s cache after turning it on.
- The flags are huge or missing. Some themes give every image a fixed size. Update WP Provider Translate first; in Elementor, set Flag width on the widget.
- The shortcode shows as text. Check the spelling and the straight quotes around option values. Some places, like a plain text field in a theme option, don’t run shortcodes; use the block or the widget there.
For developers
- The
wppt_flagfilter changes the flag of a language. It receives the country code of the flag (such asgb) and the language code (such asen), and returns a country code. See Developer filters and actions. - For your own CSS, the switcher has the class
wppt-picker, pluswppt-picker--dropdown,wppt-picker--inlineorwppt-picker--vertical; the floating one addswppt-picker--floating. Flags have the classwppt-flag, and the current language’s link hasaria-current="true". - Switcher links carry
hreflangandlangattributes. - The language banner reads the page’s
hreflangalternate links and the browser’snavigator.languages, and makes no request to your server. A click on any link with anhreflangattribute counts as the visitor’s choice. The visitor’s choice and a closed banner are kept in the browser’slocalStorage. The banner has the classwppt-suggestion(pluswppt-suggestion--rightwhen it sits on the right) for your own CSS.