Skip to content Skip to sidebar

This thread is resolved. Here is a description of the problem and solution.

Problem:
If you're experiencing an issue where hovering over the flag in the WPML language switcher displays HTML code instead of the expected tooltip or language name, this might be due to how the theme handles HTML in menu items.
Solution:
1. **Check Language Switcher Options**: Review your language switcher settings in WPML to ensure no HTML code is entered in fields meant for plain text. Navigate to WPML → Languages and check the 'Language switcher options' and 'Edit Languages' sections.
2. **Clear Caches**: If you're using a caching plugin or have server-side caching, clear these to ensure they're not causing the issue.
3. **Increase WP Memory Limit**: Increase your WordPress memory limit to at least 128MB by adding

define('WP_MEMORY_LIMIT', '256M');

in your

wp-config.php

file.
4. **Contact Theme Developers**: The issue might stem from how your theme's menu walker handles HTML. Contact your theme developers for a fix or try modifying the

start_el()

method in your theme's menu walker file to strip HTML tags from titles.
5. **Workaround**: As a temporary solution, you can add the following code to your child theme's

functions.php

to remove the title attribute for WPML switcher items:

add_filter( 'nav_menu_link_attributes', function( $atts, $item, $args, $depth ) {<br />    if ( ! empty( $item->classes ) ) {<br />        foreach ( $item->classes as $class ) {<br />            if ( strpos( $class, 'wpml-ls' ) !== false ) {<br />                $atts['title'] = '';<br />                break;<br />            }<br />        }<br />    }<br />    return $atts;<br />}, 20, 4 );

If these steps do not resolve your issue or if the solution seems outdated or irrelevant to your specific case, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If the problem persists, please open a new support ticket.

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.

This topic contains 2 replies, has 0 voices.

Last updated by andranikA 1 month, 2 weeks ago.

Assisted by: Bobby.

Author Posts
December 10, 2025 at 5:20 pm #17653364

andranikA

when I hover over the flag (language switcher), it shows the HTML code

December 10, 2025 at 10:21 pm #17653943

Bobby
WPML Supporter since 04/2015

Languages: English (English )

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

Hi there,

This issue is coming from the way the theme handles and filters HTML.

While WPML provides the language switcher it is the theme that renders and displays it in the header and menu.

The reason the WPML language switcher is showing raw HTML (for example <span> tags) when hovering over menu items is due to a behavior in the theme’s mega-menu walker. The walker incorrectly injects the full menu title—including WPML’s HTML markup—into the HTML title attribute of the menu link.

This is not a WPML problem. It comes from the way the theme’s menu walker handles menu item attributes.

The recommended next steps are to contact your theme developers as they can resolve this from their side by adjusting the code.

The problematic code is in :
ova-megamenu/inc/class-process.php
class Ova_Megamenu_Walker_Nav_Menu extends Walker_Nav_Menu {

Inside its start_el() method is the problematic line:
$atts['title'] = ! empty( trim( $item->attr_title ) ) ? $item->attr_title : $item->title;

Replacing it with the following should resolve.

$atts['title'] = ! empty( trim( $item->attr_title ) )
? wp_strip_all_tags( $item->attr_title )
: '';

Another option you can try as a workaround is to add the following code in
your child theme's functions.php

add_filter( 'nav_menu_link_attributes', function( $atts, $item, $args, $depth ) {

    if ( ! empty( $item->classes ) ) {
        foreach ( $item->classes as $class ) {
            if ( strpos( $class, 'wpml-ls' ) !== false ) {
                // Remove the title attribute for WPML switcher items
                $atts['title'] = '';
                break;
            }
        }
    }

    return $atts;
}, 20, 4 );

IMPORTANT NOTE: If you attempt this please note that we have not fully tested the code and it's simply a workaround, the proper fix should come from the theme developers.

Also before implementing any code changes provided by our team you should always have a working backup in place.

December 11, 2025 at 1:36 pm #17656102

andranikA

Thank you very much — the code you sent resolved my issue completely.
Everything is working correctly now.

I really appreciate your help and patience throughout this process.