Skip Navigation

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

Problem:
The client needs to add an ALT attribute to the language flag icons.
Solution:
We recommended the steps provided in a previously resolved support ticket. Before proceeding, ensure to perform a full site backup.

Got to ../wp-content/plugins/sitepress-multilingual-cms/classes/language-switcher/ directory and edit the class-wpml-ls-model-build.php, line 190.
Remove this line:

$ret[ $code ]['flag_alt']   = ( $display_name || $display_native ) ? '' : $data['translated_name'];

Replace it with this line:

$ret[ $code ]['flag_alt']   = ( $display_name || $display_native ) ? $data['native_name'] : $data['translated_name'];

Refer to the following links for more details:

If this solution does not seem relevant to your issue, please do not hesitate to open a new support ticket with us here.

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.

Tagged: 

This topic contains 1 reply, has 2 voices.

Last updated by Bigul 1 year, 5 months ago.

Assisted by: Bigul.

Author Posts
December 15, 2023 at 12:28 pm #15072303

alessandroB-71

How can I add and ALT Attribute to the Language Flag Icons?

December 15, 2023 at 1:05 pm #15072545

Bigul
WPML Supporter since 01/2013

Languages: English (English )

Timezone: Europe/Vienna (GMT+02:00)

Hello,

Welcome to the WPML support forum. I will do my best to help you to resolve the issue.

Please try the steps suggested in the following ticket(in its resolved summary) after a full site backup{mandatory} and make sure you are getting the expected results or not.

https://wpml.org/forums/topic/wpml-ls-flag-alt-atributes/

https://wpml.org/errata/missing-alt-tag-for-flag-image-in-a-language-switcher/

--
Thanks!

Bigul