Skip Navigation

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 Mihai Apetrei 1 year, 10 months ago.

Assisted by: Mihai Apetrei.

Author Posts
July 18, 2023 at 10:25 am #14058145

ugurE

I am trying to add an extra language switcher to the mobile header part but cant get it to work i tried several codes in the function php file

function add_wpml_switcher_to_mobile_menu_bridge($items, $args) {
if ($args->theme_location === 'mobile_menu') {
$switcher_code = wpml_lang_switcher(['dropdown_items' => 3]); // Customize the number of dropdown items as needed
$items = '<li class="menu-item wpml-switcher">' . $switcher_code . '' . $items;
}
return $items;
}
add_filter('wp_nav_menu_items', 'add_wpml_switcher_to_mobile_menu_bridge', 10, 2);

July 19, 2023 at 10:05 pm #14068771

Mihai Apetrei
WPML Supporter since 03/2018

Languages: English (English )

Timezone: Europe/Bucharest (GMT+03:00)

Hi there.

I recommend using something like these examples here:
https://wpml.org/documentation/getting-started-guide/language-setup/language-switcher-options/adding-language-switchers-using-php-and-shortcodes/

That should help.

Kind regards,
Mihai Apetrei