Switcher
The language switcher
The language switcher is a list of links, one per language. You add it with the language switcher shortcode or, in a theme, with a template tag.
The language switcher shortcode
Add [vabelon_switcher] to a page, a widget or a Shortcode block. The language switcher shortcode takes no options.
In a theme template
<?php vabelon_switcher(); ?>
What it shows
- On a page or post, it links to the published translations of that page. If the page has no translations, nothing is shown.
- Everywhere else, it links to the home address of each language.
- Each language appears under its name in that language, and Vabelon marks the current one.
Styling it
Vabelon adds no stylesheet, so the switcher takes the look of your theme. These are its classes:
.vabelon-switcher
.vabelon-switcher__list
.vabelon-switcher__item
.vabelon-switcher__link
.vabelon-switcher__link--current
A simple horizontal switcher:
.vabelon-switcher__list { display: flex; gap: 1rem; list-style: none; margin: 0; padding: 0; }
.vabelon-switcher__link--current { font-weight: 600; }
The markup
<nav class="vabelon-switcher" aria-label="Languages">
<ul class="vabelon-switcher__list">
<li class="vabelon-switcher__item">
<a class="vabelon-switcher__link vabelon-switcher__link--current" href="https://example.com/about-us" hreflang="en-US" aria-current="page"><span lang="en-US">English</span></a>
</li>
<li class="vabelon-switcher__item">
<a class="vabelon-switcher__link" href="https://example.com/es/sobre-nosotros" hreflang="es"><span lang="es">Español</span></a>
</li>
</ul>
</nav>
The switcher is a nav element with the label “Languages”. The current language carries aria-current="page", and each name carries its own lang, so screen readers pronounce it correctly. When there are fewer than two languages to show, the switcher prints nothing.
For placement and more CSS, read the guide on how to add a language switcher to WordPress. Developers will also find the classes in hooks and CSS classes.