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.

This topic contains 2 replies, has 2 voices.

Last updated by stevenV-3 6 years, 4 months ago.

Assigned support staff: Bruno.

Author Posts
March 13, 2014 at 3:28 pm #358550

stevenV-3

Hi,

I'm wondering if it is possible to have another language changer than the flags or the languages fully written? I would like to have as choices NL | FR | EN ... this is quite important as I'm having customers that are disturbed by the dutch and french flags, as I'm based in Belgium, but the Belgian flag can't be used as we have french and dutch speaking people in our country...

If this is not yet possible now, will it be possible in the future please with an update? A lot of websites have a language changer like that (see printscreen for example).

Thanks in advance!

March 13, 2014 at 9:43 pm #358718

Bruno

Dear Steven

Please add this code in the functions.php file of your theme:

function wpml_custom_menu() {
	if (function_exists('icl_get_languages')) {
		$languages = icl_get_languages('skip_missing=0');
		$items = "";

		$langnum = count($languages);
		$langn = 1;
		if(1 < count($languages)){
			foreach($languages as $l){
				$b = ( $langn < $langnum ) ? ' | ' : '';
				$items = $items.'<li class="menu-item-'.$l['language_code'].'"><a href="'. $l['url'].'">'.strtoupper($l['language_code']).'</a>'.$b.'</li>';
				$langn++;
			}
		}

		return $items;
	}
}

To use this feature, add this code where you want to display the flags:

<?php echo wpml_custom_menu(); ?>

Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.

Thank you.

March 28, 2014 at 4:22 pm #369592

stevenV-3

Hi Bruno,

thanks for the help and sorry I didn't answer yet... To be honest, I didn't try the code you gave me as it isn't that urgent: it was also a question just to be sure if it is possible, for when I sell websites that need to be multilangual and the customer prefers not to have the flags.
So thanks again, I'm sure it will work and when I need the code to do this I'll come back here to copy! 🙂