-
-
Save nicomollet/47ba9808f3187c9f1568d8f7c4355b54 to your computer and use it in GitHub Desktop.
<?php | |
/** | |
* Polylang Shortcode - https://wordpress.org/plugins/polylang/ | |
* Add this code in your functions.php | |
* Put shortcode [polylang_langswitcher] to post/page for display flags | |
* | |
* @return string | |
*/ | |
function custom_polylang_langswitcher() { | |
$output = ''; | |
if ( function_exists( 'pll_the_languages' ) ) { | |
$args = [ | |
'show_flags' => 0, | |
'show_names' => 1, | |
'echo' => 0, | |
]; | |
$output = '<ul class="polylang_langswitcher">'.pll_the_languages( $args ). '</ul>'; | |
} | |
return $output; | |
} | |
add_shortcode( 'polylang_langswitcher', 'custom_polylang_langswitcher' ); |
That code works fine for me :) But I have a question, Is it possible to put this language switcher in header? Now it works only on my page content, but not in header.
Hello, if possible, using [polylang_langswitcher] in the header, keep in mind that this only works with the code box.
Additionally, your header must have the ability to display custom code.
Which page builder are you using?
That code works fine for me :) But I have a question, Is it possible to put this language switcher in header? Now it works only on my page content, but not in header.
Hello, if possible, using [polylang_langswitcher] in the header, keep in mind that this only works with the code box.
Additionally, your header must have the ability to display custom code.
Which page builder are you using?
Thanks for your reply :)
I managed to place language switcher in header :)
That code works fine for me :) But I have a question, Is it possible to put this language switcher in header? Now it works only on my page content, but not in header.