Dynamic Web Lab

How to Use the WPML Language Switcher Shortcode to Display Multilingual Options

If you’re running a multilingual WordPress website, providing a user-friendly language switcher is essential for enhancing user experience. WPML (WordPress Multilingual Plugin) offers several ways to integrate a language switcher, but one of the most flexible and efficient methods is through the WPML Language Switcher Shortcode.

In this post, we’ll walk you through what the shortcode does, how to implement it, and why it’s a smart choice for multilingual site management.

What Is the WPML Language Switcher Shortcode?

The WPML Language Switcher Shortcode allows you to display a language switcher anywhere on your WordPress site—whether it’s inside a post, page, widget, or even a custom layout. Instead of relying solely on widget areas or menu placements, this shortcode offers a more flexible approach.

WPML also provides a built-in action hook:

do_action('wpml_add_language_selector');Code language: JavaScript (javascript)

This outputs the language switcher based on the configuration you’ve set in the Custom Language Switchers section under WPML ? Languages.

However, for content areas or block-based themes, using the shortcode is often much more convenient.


How to Use the Shortcode

function language_switcher_fun( $atts ){
	ob_start();
	do_action('wpml_add_language_selector');
	return ob_get_clean();
}
add_shortcode( 'language_switcher_shortcode', 'language_switcher_fun' );
Code language: PHP (php)

To display the language switcher using a shortcode, simply add the following to any content area:

[language_switcher_shortcode]Code language: JSON / JSON with Comments (json)

This will render the language switcher based on your predefined settings. You can place it in:

• WordPress posts and pages

• Elementor or Gutenberg blocks

• Footer or header widget areas

• Custom HTML areas in your theme


Benefits of Using the WPML Language Switcher Shortcode

Here are some of the main advantages:

Flexible Placement: Add the switcher exactly where you want it, without modifying template files.

Consistent Styling: Automatically inherits styling from your WPML settings.

Ease of Use: No coding required—just copy and paste the shortcode.

Responsive Design: Fully mobile-friendly and compatible with modern themes and builders.


Best Practices for Implementation

• Configure your language switcher style under WPML ? Languages before using the shortcode.

• Test the shortcode on various devices to ensure responsiveness.

• Combine with Elementor or Gutenberg for better design control.

• Avoid placing multiple switchers on the same page unless necessary.

The WPML Language Switcher Shortcode is a simple yet powerful tool for adding multilingual functionality to your WordPress site. Whether you’re building with Elementor, Gutenberg, or classic editors, this shortcode gives you full control over placement and integration.

The do_action('wpml_add_language_selector'); action outputs the language switcher based on the options set in the Custom Language Switchers section in WPML ? Languages.

You can use it like this [language_switcher_shortcode]

Written by

Maidul Islam

I am a freelance web developer.Like to share what i learn.