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 2 voices.

Last updated by jakobL-3 12 months ago.

Assigned support staff: Marcos Vinicios Barreto.

Author Posts
October 24, 2018 at 12:34 pm #2846189

jakobL-3

I am trying to:

Link to a page where the issue can be seen:

I expected to see: Language switcher appearing in mobile/reponsive theme

Instead, I got: No switcher

October 24, 2018 at 6:26 pm #2847617

Marcos Vinicios Barreto
Supporter

Languages: English (English ) Portuguese (Brazil) (Português )

Timezone: America/Bahia (GMT-03:00)

Hello,

Thank you for contacting WPML Support. Regarding your request:

1 - Where do you have your language swicher inserted in your theme? Is it attached to your main menu or do you have it in any other location using a Widget or custom code for example? Most themes use the main menu in the responsive navigation as well. Is it your case here? If so you can make sure:

1.1 - You have a language switcher attached in your main menu from your WordPress Dashboard > WPML > Languages > Menu language switcher settings.

2 - If you have your language switcher inserted as a widget and you don't have the widget area available in the responsive view of your website, then you should consider a custom language switcher using a custom PHP code, here is how to proceed:

2.1 - Browse to your child theme folder and open the functions.php file, there insert this code:

function my_custom_language_switcher() {
    $languages = apply_filters( 'wpml_active_languages', NULL, 'orderby=id&order=desc' );
 
    if ( !empty( $languages ) ) {
        foreach( $languages as $l ) {
            if ( !$l['active'] ) echo ' <a href="' . $l['url'] . '">';
            echo '<img src="' . $l['country_flag_url'] . '" height="12" alt="' . $l['language_code'] . '" width="18" />';
            if ( !$l['active'] ) echo '</a> ';
        }
    }
}

2.2 - Copy the desired template file where you need to show your language switcher from your parent theme folder into your child theme folder and try the custom code below:

<?php function my_custom_language_switcher(); ?>

IMPORTANT: We always recommend you make a backup of your website before any manual intervention to your theme files.

In any case I would need to take a look in your website so I can determine how's the best approach here. Please, if it is possible, provide us with your website url.

Please, let me know if you need any additional clarifications from our site, have a nice day.

October 25, 2018 at 6:23 am #2848782

jakobL-3

My issue is resolved now. Thank you!