• Apr
  • 19
  • 2012

How to display language flags for different languages in WPML WordPress ?

When you are using WPML in wordpress at that time you might have come across the requirement for placing the flag icons of different languages.

You can show flags from WPML settings itself and also by writing a very small code wherever you wish to display the flags.

It will automatically show the flag icons of the different languages in which you have made your website.There is no need to do anything more than that. You just have to write the below code.

Code for displaying language flags for different languages :

function language_selector_flags(){
$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'].'" alt="'.$l['language_code'].'" />';
if(!$l['active']) echo '</a>';

You can also place your html tags for having the look of flags as per your site’s look.

Isn’t it very simple???

Ravi Makhija

Ravi Makhija

A writer, an Entrepreneur. Curious about the internet of everything. Interested in the cutting edge landscape of mobile apps and SAAS products. Blogs for Guru Technolabs - A Mobile App Development Company.

Let's Discuss a Project

Please share your unique idea or project requirement with us, our business concern person will get back to you with further details.