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.

This topic contains 2 replies, has 0 voices.

Last updated by andranikA 13 hours, 41 minutes 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.