Guide

WPML Language Switcher Advanced Customization Guide

Elizabeth Pokorny
Written by
Elizabeth Pokorny
Elizabeth Pokorny
Written by
Elizabeth Pokorny
Reviewed
Reviewed by
WPML Language Switcher Advanced Customization Guide

WPML is one of the oldest translation plugins for WordPress and they’ve rightfully developed a great reputation in the multilingual WordPress space.

The WPML language switcher feature lets you create a front-end option for your visitors to choose their preferred language on your WordPress site.

However, some people struggle with the style and positioning of the WPML language switcher.

This guide will help you master the WPML language switcher by covering:

  • Basic functionality
  • Advanced customization techniques
  • Troubleshooting common issues
  • Optimization tips for better user experience

We'll also briefly touch on Weglot in comparison to WPML’s language switcher, which you might find useful as an alternative solution to WPML.

How to Add the WPML Language Switcher to Your Website

Add the WPML Language Switcher to your site with the following instructions:

  1. Go to WPML → Languages in the WordPress dashboard.
  2. Choose your preferred placement option.
WPML language switcher options
  1. For template or block-based themes, use the WPML Language Switcher block in the Site Editor

WPML offers various placement options for your language switcher:

  • Menus and widgets
  • Footer (default)
  • Above or below post content
  • Templates, template parts, and site navigation (using the WPML Language Switcher block)
  • Custom locations using PHP or shortcodes

However, you cannot add a floating WPML language switcher by default. If you want to create a floating WPML language switcher, you’ll need to use your own custom code, hire a developer to do it for you or choose an alternative translation solution.

Here’s how you can set up your WPML language switcher in your chosen placement:

  1. Menus and widgets
    • Go to WPML → Languages in the WordPress dashboard.
    • Add a new language switcher to your menu or as a widget.
    • This is ideal for prominent placement in headers or sidebars.
  2. Footer (default)
    • WPML adds a language switcher to your site's footer by default.
    • You can edit this in WPML → Languages.
    • Footer placement is subtle yet accessible across all pages.
  3. Above or below post content
    • In WPML → Languages, scroll to "Links to translation of posts".
    • Check the box to enable and configure options.
    • This is particularly useful for blogs or news sites with frequent content updates.
  4. Templates, template parts, and site navigation
    • Use the WPML Language Switcher block in the WordPress Site Editor.
    • Remember to translate the block for it to appear in secondary languages.
    • This method offers the most flexibility for block-based themes.
  5. Custom locations
    • Use PHP or shortcodes to add the language switcher to custom locations.
    • This advanced option allows for unique placements tailored to your site's design.

When setting up your language switcher, you can customize its appearance:

  • Choose to display flags (SVG by default, with an option for PNG)
  • Show languages in their native names
  • Set the order of languages to prioritize certain translations

Advanced Techniques for WPML Language Switcher Customization

Once you've got the basics down, you can dive into more advanced customization to truly tailor the language switcher to your site:

  1. Styling Options
    • Set global options for all language switchers in WPML → Languages.
    • Configure individual settings for each language switcher separately.
    • Customize colors, flag display, and language name format.
    • Pro tip: Use your brand colors for a cohesive look.
  2. Custom Flags
    • Upload your own custom flags in WPML → Languages → Edit Languages.
    • This is particularly useful for region-specific variations (e.g., US vs. UK English).
  3. URL Format Configuration: Choose from three options in WPML → Languages → Language URL Format
    • Different languages in directories (e.g., example.com/es/)
    • A different domain per language (e.g., es.example.com or ejemplo.es)
    • Language name added as a parameter (e.g., example.com/?lang=es) Consider SEO implications when choosing your URL structure.
  4. SEO Optimization:
    • Enable hreflang links in WPML → Languages → SEO Options.
    • Choose the position of hreflang links (early or later in the head section).
    • This helps search engines understand your site's language variations.
  5. Custom Language Switchers:
    • Create custom language switchers using PHP API for advanced users.
    • This allows for unique designs like floating language selectors.
  6. Admin Language:
    • Set different admin languages for individual users in Users → Profile.
    • Useful for multilingual teams managing the site.

Remember, with great power comes great responsibility. Test thoroughly after making advanced changes to ensure everything works as expected.

Troubleshooting Common WPML Language Switcher Problems (Plus an Alternative)

Even with careful setup, you might encounter issues. Here are some common problems and their solutions:

  1. CSS conflicts:
    • If the language switcher doesn't display correctly, check for CSS conflicts with your theme.
    • Use browser developer tools (such as your viewport) to inspect and adjust CSS as needed.
    • Try adding custom CSS to override conflicting styles.
  2. Missing translations:
    • Ensure your content is properly translated in all languages.
    • Check WPML → Translation Management for any pending translations.
    • Use WPML's Translation Editor to manage translations efficiently.
  3. Performance issues:
    • Consider enabling WPML's built-in caching features.
    • Enable the JavaScript cookie for proper AJAX filtering on cached sites.
    • Optimize your server and use a good caching plugin for overall site speed.
  4. Language switcher not appearing:
    • Verify that the language switcher is enabled for your chosen locations in WPML → Languages.
    • Check if your theme supports WPML's default hooks.
  5. Incorrect language order:
    • Review and adjust the language order in WPML → Languages → Language switcher options.
    • Remember, the current language always appears first in dropdown switchers.

If you're consistently struggling with these issues, you might want to consider an alternative solution.

The Top WPML Language Switcher Alternative

While WPML offers robust language switching capabilities, some users find Weglot to be a more user-friendly alternative. Here's why Weglot stands out as a top WPML language switcher alternative:

  1. Easy setup: Weglot translates your entire WordPress site and adds a language switcher within minutes of activation.
  2. Floating language switcher: Unlike WPML, Weglot provides a floating language switcher by default, without requiring custom code.
  3. Flexible placement options: Similar to WPML, Weglot allows you to add the language switcher as a menu item, widget, shortcode, or in your site's code.
  4. Customization without coding: Weglot offers easy customization options for the language switcher's appearance, including:some text
    • Dropdown menu format
    • Country flag display (with various styles)
    • Language name display (full name or country code)
  5. Automatic translation: Weglot starts with machine translation for quick multilingual setup, allowing manual refinement later.
  6. Visual translation interface: Weglot provides a unique visual editor for translating your site content, making it easier for non-technical users.
  7. Browser language redirection: Automatically redirect visitors to their preferred language based on their browser settings.
  8. Comprehensive translation management: Weglot's interface allows for easy management of all site translations, including theme and plugin content.

To add your language switcher with Weglot, sign up for a Weglot account, install and connect the plugin, and choose the original language and destination language(s) that you want to use:

Choosing destination languages on Weglot

As soon as you activate the plugin, Weglot uses automatic translation to translate your site, and it also automatically adds a floating language switcher in the bottom-right corner.

You can see the language switcher on the homepage below:

Sample language switcher with Weglot

So within the first few minutes, you’re already up and running with a multilingual site and a front-end language switcher.

For users seeking a simpler solution with advanced features out-of-the-box, Weglot offers a compelling alternative to the WPML language switcher.

Pick the Language Switcher That Works Best for You

The WPML language switcher and Weglot’s language switcher both let you add a front-end language switcher to your WordPress site, but there are key differences between WPML and Weglot.

Neither approach is inherently better, but you might prefer Weglot’s approach if you’re looking for a simpler solution because it will let you add a floating language switcher and/or customize your language switcher’s looks without needing any custom code or technical knowledge.

If you want to try the Weglot language switcher for yourself, sign up for a 10-day free trial to see how it works.

In this guide, we're going to look into:

Explore more about working with Weglot

Try for free