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 4 replies, has 2 voices.

Last updated by doug 7 years, 11 months ago.

Assigned support staff: Bruno.

Author Posts
May 27, 2013 at 3:38 pm #130698

doug

How can I change the flags to text only? Is it possible to show only the other language available as a text link? The site is French and English. When on an English page, I would like to only see the option for French as a text link. Does that make sense?

from header.php

<?php $top_area_type = theme_get_option('general','top_area_type');
	switch($top_area_type){
		case 'html':
			if(theme_get_option('general','top_area_html')){
				echo '<div id="top_area">';
				echo str_replace(array('[raw]','[/raw]'),'',do_shortcode(wpml_t(THEME_NAME, 'Top Area Html Code', stripslashes( theme_get_option('general','top_area_html') ))));
				echo '</div>';
			}
			break;
		case 'wpml_flags':
			theme_generator('wpml_flags');
			break;
		case 'widget':
			echo '<div id="top_area">';
			dynamic_sidebar(__('Header Widget Area','striking_admin'));
			echo '</div>';
			theme_generator('wpml_flags');
			break;
	}
?>

May 27, 2013 at 6:02 pm #130732

Bruno

Dear Doug,

You can use the function icl_get_languages() to catch all languages and manipulate as you wish. The code below shows how you can do this.

<?php
if( function_exists('icl_get_languages') ):
	$languages = icl_get_languages('skip_missing=0');

	$link = '<ul>';
	foreach($languages as $language) {

		if($language['active']) {
			$link .= '<li><img src="' . $language['country_flag_url'] . '" alt="' . $language['native_name'] . '" /> ' . $language['native_name'] . '</li>';

		} else {
			$link .= '<li><a href="' . $language['url'] . '"><img src="' . $language['country_flag_url'] . '" alt="' . $language['native_name'] . '" /> ' . $language['native_name'] . '</a></li>';
		}
	}
	$link .= '</ul>';

	echo $link;
endif;
?>
May 27, 2013 at 7:35 pm #130751

doug

Hi Bruno,
I'm not quite sure what to do with your code. What do I do next?

Thanks for the quick reply!

May 28, 2013 at 1:26 pm #130941

Bruno

Dear Doug,

You must add this code where you want it to appear the list of languages​​.

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.

May 31, 2013 at 1:45 pm #131878

doug

I'm sure the code works. Just not for me. My theme is not very accomodating.