How to show the inactive language only from the language selector?


I have a multi-language site (En, Ar) and I’m using Switch B from the [docs] ( to make my language selector.

Is there a PHP/Kirby way to just show the inactive language? Currently, I’m using a hacky CSS way to hide the active language from the selector.

<nav class="languages">
    <?php foreach($kirby->languages() as $language): ?>
    <?php if ($kirby->language() == $language) continue; ?>
      <a href="<?= $page->url($language->code()) ?>" hreflang="<?php echo $language->code() ?>">
        <?= html($language->name()) ?>
    <?php endforeach ?>

This is what I’m missing. Been trying to do the If statement but always gives an error or still shows both language.

As always, to the rescue. Thank you @texnixe