0

I want to show the language selector on my site but with the default include code "icl_language_selector" it shows the language full name. I only want to show the abbreviations of the language. For example ...

English = ENG
French = FR

Is this possible and how can I pull this off?

0

I dealt with this writing a custom template tag. You may want to adjust the structure and classes in order to fit the needs of your styling:

function mysite_languages() {
  if ( function_exists( 'icl_get_languages' ) ) :
    $languages = icl_get_languages( 'skip_missing=N&orderby=KEY&order=DIR&link_empty_to=str' );
    if ( ! empty( $languages ) ) :
      echo "\n<ul class=\"languages\">\n";
      foreach ( $languages as $lang ) :
        echo '<li class="' . ( $lang['active'] ? 'active' : ''  ) . '"><a href=' . $lang['url'] . '>' . $lang['language_code'] . "</a></li>\n";
      endforeach;
      echo "</ul>\n";
    endif; // ( ! empty( $languages ) )
  endif; // ( function exists )
}

Further reference on WPML page: http://wpml.org/documentation/getting-started-guide/language-setup/custom-language-switcher/

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.