H
H
hooli-gun2021-08-26 16:42:20
WordPress
hooli-gun, 2021-08-26 16:42:20

How to make Polylang language switcher?

How to make a switch output like this?
612799e6e92f6185402193.png

I found this code, but I don't know how to display the flag

<?php 
          $translations = pll_the_languages(array(
            "raw" => 1,
          ));
        ?>

<div class="site-language dropdown">
          <button class="site-language__btn" type="button" id="language-dropdown-btn" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
            <img src="">
            <span class="site-language__text"><?= $translations[pll_current_language()]['name'] ?></span>
          </button>
          <div class="language-dropdown" aria-labelledby="language-dropdown-btn">
            <?php foreach ($translations as $item) : ?>
            <a class="language-item <?= ($item['current_lang']) ? 'disabled' : '' ?> language<?= $item['name'] ?>" href="<?= $item['url'] ?>"><img src=""><?= $item['name'] ?></a>

            <?php endforeach; ?>
          </div>
        </div>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladik Bubin, 2021-08-26
@ikoit

Language switcher in Polylang plugin, wordpress?
Flags can be done with :before.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question