Language Switcher — Dropdown, List, or Flag Selector
Every multilingual WordPress site needs a way for visitors to switch languages. Lang Forge ships four styles of language switcher. Add one as a widget or a shortcode without editing your theme, or call it from a template.
Four styles
1. Dropdown
A compact dropdown: a link showing the current language, with a list of the languages under it. The list opens while the pointer is over the link or the list and also while keyboard focus is on the link or on a language in the list, so it can be opened with the Tab key. Best for headers where space is tight, or for sites with more than five languages.
2. List
A list of links side by side, wrapping onto a new line when they do not fit, with the current language in bold. Best for footers, sidebars, and any place where you want visitors to see all available options at a glance.
3. Flag selector
Country flags in a row, each one linking to its language, with the native name of the language as a tooltip. This style prints no language names next to the flags; the Dropdown and List styles can show them. Best for visual impact in a header. Flags are SVG assets and scale cleanly on any display.
4. Plain
Unstyled links in a row, with no dropdown. Best when your theme styles the links itself.
The shortcode and the template function take their defaults from the Language Switcher card on Lang Forge > Settings: Style, Show flags, Show language names, and Show current language in list. The switcher lists the active languages that have the Switcher box ticked on Lang Forge > Languages. If you tick Hide languages with no translations, a language that has no published translated post or page on the site is left out, and the default language always stays.
Ways to place the switcher
As a widget
Drag the Lang Forge Language Switcher widget into any sidebar or widget area. Configure style, show/hide flags, show/hide language names. Done.
As a shortcode
Use [langforge_language_switcher] anywhere shortcodes are supported — post content, widgets, page builder text blocks, theme templates. Shortcode parameters control the style, whether flags and names are shown, and whether the current language is listed:
[langforge_language_switcher style="dropdown" show_flags="yes" show_names="yes" show_current="yes"]
From a theme template
Lang Forge does not add a switcher item to Appearance → Menus. To put the switcher in a header or navigation area, use a widget area, the shortcode, or echo the result of langforge_language_switcher() in your theme template.
In the WordPress admin bar
When two or more languages are active, logged-in users who see the WordPress admin bar get a Lang Forge language item in it. On the front end it lists the other active languages, and each one links to the home page in that language.
No theme-specific code
The language switcher uses no theme-specific code. It renders as semantic HTML with CSS classes you can override in your theme’s stylesheet. The default CSS is minimal.
Accessibility
- The dropdown style is a
<ul>list inside a<div>. Its only top-level item is a link that shows the current language, with a sub-list of the languages under it. A CSS rule shows the sub-list while the pointer is over the item, and a second rule shows it while focus is on the current-language link or on a link inside the sub-list, so the list opens when you Tab to the link. The link hashref="#"andaria-haspopup="true". No script is involved, so the link carries noaria-expandedattribute. The current-language link and the language links in the sub-list get a visible outline while they have keyboard focus - The list style is a
<ul>of links, the flags style is a<div>of links, and the plain style is a<span>of links. In every style the languages are ordinary links. None of the styles wraps the links in a<nav>element or gives the switcher itself a role attribute - In the plain style the link of the current language has
aria-current="true". The other styles mark the current language with the CSS classwpml-ls-current-languageonly - A flag shown as an image has the native name of the language as its alt text. A flag drawn as an emoji has
role="img"and the native name as itsaria-label. Each link of the flags style also carries the native name as its title
Ready to add a language switcher?
The language switcher is included in every paid plan — and in the free version on WordPress.org.