Translate Smart Slider 3 with WPML

You have set up a multilingual site with WPMLyou use Smart Slider 3 to create dynamic, visual sliders… and now you’re thinking :

“Here, it would be nice to have a different slider for each language.”

But here’s the thing: it’s not that easy to change sliders according to language. WPML doesn’t automatically detect the slider ID in the [smartslider3 slider="2"] shortcode, and you get stuck in the translation editor. There’s no field allowing you to replace that famous number “2”.

On the WPML side, there are several methods for translating custom shortcodes (see the official documentation here).
But in the specific case of Smart Slider 3, only the “Translate hardcoded texts inside shortcodes” approach really works. Other methods, such as attribute translation with wpml-config.xml, do not recognize numeric IDs as translatable content.

The good news? With just a few lines of code, you can set up a clean, super-efficient solution. Nothing complex, I promise: it’s quick to do, and we’ll take you through it step by step in this tutorial.

The problem with the Smart Slider 3 and WPML duo

When you add a slider to a page with Smart Slider 3, you use a shortcode of this type :

[smartslider3 slider="2"]

Simple, isn’t it? Yes… until you want to display a different slider for each language.

With WPML, you’d expect to be able to easily modify this shortcode in the translation editor. But you can’t:

  • The shortcode does not appear in the advanced translation editor.
  • WPML doesn’t provide a field for modifying the slider ID.
  • Even with a wpml-config.xml file, WPML ignores numeric attributes such as slider="2".

Result: you end up with the same slider for all languages, even if you’ve created a separate slider for English, German or Italian.

The simple (and reliable) way to display a multilingual slider

No need to complicate life with hacks or endless XML files.
The cleanest method is to save the slider shortcode as a translatable string via WPML, then automatically display the correct version of the slider according to the active language.

The idea is to translate the shortcode itself, like a classic sentence, rather than trying to modify its attributes (which WPML doesn’t manage with numeric IDs).

And the good news is that it takes just a few lines of code to set up. No need to be an experienced developer. Here are the 3 main steps:

  1. Save the shortcode as a translatable string.
  2. Translate this string for each language from the WPML interface.
  3. Create a WordPress shortcode that automatically displays the correct slider, based on the translated version of the channel.

We show it all just below

Tutorial: translating a Smart Slider 3 slider with WPML

Ready to display a different slider according to your visitor’s language? Here’s how to implement this logic in just a few minutes.

Étapes smart slider 3 et wpml

Temps

15

Minutes

Coût

0

CHF

Outils

– Accès à WordPress
– Accès au fichier functions.php (ou plugin)
– WPML avec le module Traduction de chaînes activé

Matériel

– L’ID de chaque slider Smart Slider 3 à afficher par langue
– Le shortcode [smartslider3 slider="X"] pour chaque version

Configurer Smart Slider 3 avec WPML en 4 étapes simples

Étape 1 : Enregistrer le shortcode comme chaîne traduisible

Ajoutez ce code dans le fichier functions.php de votre thème, ou dans un petit plugin personnalisé :

do_action('wpml_register_single_string', 'SmartSlider', 'home_slider_shortcode', '[smartslider3 slider="5"]');

Remplacez 5 par l’ID du slider que vous souhaitez afficher dans la langue par défaut de votre site (par exemple, le slider en français si c’est votre langue principale).

Étape 2 : Traduire la chaîne dans WPML

1. Rendez-vous dans WPML → Traduction de chaînes
2. Filtrez par domaine : SmartSlider
3. Recherchez la chaîne home_slider_shortcode
4. Ajoutez les traductions :
5. Anglais → [smartslider3 slider="2"]
6 Allemand → [smartslider3 slider="7"]
etc.

Étape 3 : Créer un shortcode qui affiche automatiquement le bon slider

Ajoutez maintenant ce code (dans le même fichier function.php) :

add_shortcode('translated_slider', function() { $shortcode = apply_filters( 'wpml_translate_single_string', '[smartslider3 slider="5"]', // valeur par défaut (français) 'SmartSlider', 'home_slider_shortcode' ); return do_shortcode($shortcode); });
Ce shortcode va afficher la bonne version du slider selon la langue active sur le site. Magique

Étape 4 : Utiliser le shortcode dans Gutenberg ou Elementor

Dans Gutenberg :
– Ajoutez un bloc Shortcode
– Collez : [translated_slider]
Dans Elementor :
– Ajoutez un widget Shortcode
– Insérez : [translated_slider]
– Et voilà, c’est en place ! Chaque langue affichera son propre slider sans duplication de page ou logique conditionnelle compliquée.

Why wpml-config.xml is not enough

WPML lets you configure the translation of shortcode attributes via a wpml-config.xml file.
In the case of Smart Slider 3 with WPML, you could write :

And indeed, in some cases, WPML will display a field to modify the value of the slider attribute, even if it’s a simple number like "2".

But beware: this solution is far from ideal.

Why?
Because WPML doesn’t know that this number corresponds to a slider ID. It displays it as a simple text string, with no context or explanation. Result:

  • The field is difficult to locate in the editor.
  • It is not clear to the translator.
  • And in some cases (page builders, widgets, blocks), the attribute may not appear at all, or may not be taken into account at display time.

That’s why we recommend a more reliable method: translate the entire shortcode as a WPML string, which guarantees consistent, comprehensible behavior in any language.

In short: the method that really works

Translating a Smart Slider 3 slider with WPML isn’t magic… but it’s not rocket science either. With a few lines of code and the right method, you can finally display the right slider in the right language, just as you’ve always wanted.

To remember:

  • Forget wpml-config.xml in this case
  • Save the complete shortcode as a WPML string
  • Use a small WordPress shortcode to display the translated version automatically

And there you have it: no more duplicating pages, no more tinkering in the editor. Your site is clearer, cleaner, and your visitors will see a slider that speaks their language – literally.

Frequently asked questions (FAQ)

Need help setting up this solution on your site?

Discover our expertise as a web agency or contact us for personalized support and optimize your multilingual site today.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *