WordPress WPML Custom Language Switcher

Just add this code snippet anywhere in your template where you want switcher to appear.

<ul class="lang-switcher">
    <?php 
        $languages = 	icl_get_languages('skip_missing=N&orderby=KEY&order=DIR&link_empty_to=str');
        foreach($languages as $language){
        $flag = $language['country_flag_url'];
        $url =  $language['url'];
        $isActive = $language['active'];
        $name = $language['native_name']
    ?>
    
    <li><a href="<?php echo $url; ?>" <?php if($isActive == 1){ ?> class="active" <?php } ?>>
            <img src="<?php echo $flag; ?>" alt="<?php echo $name; ?>" />
        </a></li>
    
    <?php } ?>
</ul>

Source