Adding language selection to the code ? (WPML plugin )


	function language_selector_flags(){
                // get array from this function
		$languages = icl_get_languages('skip_missing=0&orderby=code');
			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" />';
				echo icl_disp_language($l['native_name'], $l['translated_name']); //DISPLAY LANGUAGE NAME

				if(!$l['active']) echo '</a>';

	<div id="flags_language_selector"><?php language_selector_flags(); ?></div >

You may have to add some css make it look better like the following :

#flags_language_selector {

 float: right;
 padding:0 5px;


#flags_language_selector img{
 border:1px solid #333;


For more information check the following link :

Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: