SahilMepani
6/20/2017 - 6:59 PM

WPML: Language switcher with only flags

WPML: Language switcher with only flags

<?php
  /*=========================================================
  =            WPML language switcher only flags            =
  =========================================================*/
  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" />';
        if ( ! $l['active'] ) echo '</a>';
      }
    }
  }
?>