9.4 Custom Switchers with Code (for developers or full control)

Add anywhere in your theme (header.php, footer.php, templates):

<!-- Simple dropdown -->
<?php do_action('wpml_add_language_selector'); ?>

<!-- Full custom example -->
<div class="my-custom-switcher">
    <?php
    $languages = apply_filters('wpml_active_languages', NULL, 'orderby=name&order=asc');
    if ($languages) {
        foreach($languages as $l) {
            echo $l['active'] ? '<span class="active-lang">'.$l['native_name'].'</span>' : 
                 '<a href="'.$l['url'].'">'.$l['native_name'].'</a>';
        }
    }
    ?>
</div>

Last updated