Skip to content Skip to sidebar

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: America/Los_Angeles (GMT-07:00)

This topic contains 3 replies, has 0 voices.

Last updated by Bobby 7 months ago.

Assisted by: Bobby.

Author Posts
September 11, 2025 at 7:55 pm #17395547

steveM-3

Background of the issue:
I am trying to use the [wpml_language_switcher] shortcode to build a custom language switcher by passing in a twig template string as described in the shortcode's documentation. Since updating from WPML 4.7.6 to 4.8.1, it is no longer using the template string to generate its output.

The template code is as follows:

<div class="nav-lang col-auto">
  <?php echo do_shortcode('[wpml_language_switcher] 
    <div class="{{ css_classes }} nav-lang-switcher"> 
      <ul> 
        {% for code, language in languages %} 
          <li class="{{ language.css_classes }}"><a href="{{ language.url }}" title="{{ language.native_name }}{% if language.native_name != language.display_name %} ({{ language.display_name }}){% endif %}" class="nav-button">{{ language.code }}</a></li> 
        {% endfor %} 
      </ul> 
    </div> 
    [/wpml_language_switcher]'); 
  ?> 
</div>

Link to a page where the issue can be seen: hidden link

I have also made sure that the "Custom Language Switcher" setting is enabled.

<b>Symptoms: </b>
The expected output was a specific HTML structure for the language switcher, but instead, I got a different HTML structure that does not respect the template string.

<b>Questions: </b>
Why is the

wpml_language_switcher

shortcode not respecting the template string after updating to WPML 4.8.1?

September 11, 2025 at 8:44 pm #17395734

Bobby
WPML Supporter since 04/2015

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Hi there,

Thank you for sharing the above information!

is the expected output the version with the language switcher that has the language code as FR and a circle background behind it?

Was this styling pulled by using custom CSS on the original switcher?

September 11, 2025 at 11:36 pm #17395867

steveM-3

Yes, the expected output is the version with the circle, which was achieved with CSS. The issue is that the shortcode isn't using the template string anymore, thus no longer putting out the specific HTML for the styling.

September 16, 2025 at 1:11 pm #17406302

Bobby
WPML Supporter since 04/2015

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Thank you for updating me!

I've attempted reproducing this on a sandbox environment, but I was not successful, I would like to request temporary access (wp-admin and FTP) to your site to test the issue.
(preferably to a test site where the problem has been replicated if possible)

**Before we proceed It is necessary to take FULL BACKUP of your database and your website. Providing us with access, you agree that a backup has been taken **

I often use the Duplicator plugin for this purpose: http://wordpress.org/plugins/duplicator/
You will find the needed fields for this below the comment area when you log in to leave your next reply.
The information you enter is private which means only you and I have access to it.

NOTE: If access to the live site is not possible and the staging site does not exist please provide me with a duplicator package created with the duplicator plugin.

Thank you,
Bobby

The topic ‘[Closed] [wpml_language_switcher] shortcode no longer respecting template string after updating from WPML 4.7…’ is closed to new replies.