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 Bart 8 years, 2 months ago.

Assigned support staff: Harshad.

Author Posts
July 9, 2012 at 5:03 am #66675

Bart

How can I change the language selector widget to show only show flags of available languages in a row?

July 9, 2012 at 6:10 am #66683

Harshad

Dear Bart,

To display language selector with flags in a row, please copy the function below into your theme's functions.php file

function language_selector_flags(){
    $languages = icl_get_languages('skip_missing=0&orderby=code');
    if(!empty($languages)){
        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" style="margin:1px; border:1px solid #333;"/>';
            if(!$l['active']) echo '</a>';
        }
    }
}

Then call the above function into your header.php file wherever you want to display.

<?php language_selector_flags(); ?>
July 24, 2012 at 5:00 am #68766

Bart

Thanks, it works!

The topic ‘[Closed] Language selector widget with flags only’ is closed to new replies.