Answer the question
In order to leave comments, you need to log in
How to make Polylang language switcher?
How to make a switch output like this?
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
Language switcher in Polylang plugin, wordpress?
Flags can be done with :before.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question