Skip to content

Instantly share code, notes, and snippets.

@twentyfortysix
Last active February 13, 2016 19:39
Show Gist options
  • Save twentyfortysix/0d05db154260bec2552c to your computer and use it in GitHub Desktop.
Save twentyfortysix/0d05db154260bec2552c to your computer and use it in GitHub Desktop.
WP - WPML - custom language_switch
if (function_exists('icl_get_languages')){
$languages = icl_get_languages('skip_missing=0');
$lang_html = '';
foreach($languages as $lang){
$lang_html .= '<div';
if ( $lang['native_name'] == ICL_LANGUAGE_NAME){
$lang_html .= ' class="current-menu-item current_language lng"';
}
else{
$lang_html .= ' class="lng"';
}
$lang_html .= '><a href="'.$lang['url'].'">'.$lang['native_name'].'</a></div>';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment