Skip to content

Instantly share code, notes, and snippets.

@isotrope
Last active August 29, 2015 14:10
Show Gist options
  • Save isotrope/b7c731c8b935b5e85af4 to your computer and use it in GitHub Desktop.
Save isotrope/b7c731c8b935b5e85af4 to your computer and use it in GitHub Desktop.
Adding WPML language switcher supportFeel free to add more classes to the links or the List Items to have more control over the CSS
<?php
// Adding WPML language switcher support
// Feel free to add more classes to the links or
// the List Items to have more control over the CSS
if ( function_exists( 'icl_get_languages' ) ) {
$available_languages = icl_get_languages( 'skip_missing=0' );
foreach ( $available_languages as $l ) {
if ( ! $l['active'] ) {
$langs[] = '<a href="' . $l['url'] . '" class="language_switch_link">' . $l['native_name'] . '</a>';
}
}
echo '<span id="language_switcher">' . join( ', ', $langs ) . '</span>';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment