Language switcher and menus
The language switcher
Section titled “The language switcher”The language switcher is the list or menu that lets your visitors change language. It always takes them to the same page in the other language, not to the home page.
If a page isn’t translated into a language yet (or its translation is still a draft), that language’s link goes to its home page instead. You can also hide those languages, as explained below.
There are four ways to add it. Choose the one that fits your theme.
With a block
Section titled “With a block”This is the simplest way if your theme is a block theme (one you edit in Appearance → Editor).
- Go to Appearance → Editor and open your header.
- Add the Language Switcher (LingoPress) block, as you would add any other block (search for “Language Switcher”).
- Save.
You can also add the block to any post or page. In the block’s settings you’ll find:
- Display as dropdown: shows the languages in a drop-down list instead of side by side.
- Show language names: shows the full name (English) or just its short code (EN).
- Hide current language: doesn’t show the language the visitor is reading.
- Hide languages without translation: hides the languages the page isn’t translated into.
In a menu
Section titled “In a menu”If your theme uses Appearance → Menus:
- Go to Appearance → Menus and choose your menu.
- In Custom Links, type
#lingopress_switcherin URL and any text in Link Text (for example, Languages). - Click Add to Menu and then Save Menu.
On your site, that item turns into one link per language, with its name.
As a widget
Section titled “As a widget”If your theme has widget areas (a sidebar or a footer, for example), go to Appearance → Widgets and add the Language Switcher (LingoPress) widget. You can give it a Title and choose Display as dropdown.
With a short code
Section titled “With a short code”Wherever you can write text, you can paste this code (in the block editor, use a Shortcode block):
[lingopress_switcher]It accepts the same options as the block. Add the ones you want, with 1 for yes and 0 for no:
| Write this | To |
|---|---|
dropdown="1" |
Show it as a drop-down list. |
show_names="0" |
Show only the short codes (EN, ES). |
hide_current="1" |
Hide the language the visitor is reading. |
hide_if_no_translation="1" |
Hide the languages the page isn’t translated into. |
For example: [lingopress_switcher dropdown="1"].
A menu for each language
Section titled “A menu for each language”If your theme uses Appearance → Menus, you can show a different menu in each language, with the names of your pages already translated:
- Go to Appearance → Menus and create a menu for each extra language (for example, Main menu — English), with the links to the pages in that language.
- Open Manage Locations. Next to each location of your theme you’ll see one more per language, for example Primary Menu — English.
- Assign each menu to its location and click Save Changes.
From then on, the pages in English show the English menu, and the rest show your usual menu.
With a block theme
Section titled “With a block theme”With block themes, the menu is part of the header. To show a different one in each language:
- Translate your header in LingoPress → Templates (see Your content in each language).
- Click Edit on that language’s version and, in its Navigation block, choose or create the menu in that language.
Keep in mind that ✦ Re-translate replaces that version, so you’d have to choose the menu again.
Show a widget only in one language
Section titled “Show a widget only in one language”Each widget has the option The widget is displayed for:, where you choose All languages or a single one. It’s handy for a promotion, a notice or a contact form that only makes sense in one language.
This option appears on the classic widgets in Appearance → Widgets. Blocks added to a widget area don’t have it.
