Forked from nicomollet/polylang-langswitcher-shortcode.php
Last active
April 20, 2022 15:24
-
-
Save ONEKENO/8622274a0de6196d06446098839cedd5 to your computer and use it in GitHub Desktop.
Polylang shortcode for lang switcher
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 inline-block | |
* | |
* @return string | |
*/ | |
function custom_polylang_langswitcher() { | |
$output = ''; | |
if ( function_exists( 'pll_the_languages' ) ) { | |
$args = [ | |
'show_flags' => 1, | |
'show_names' => 0, | |
'echo' => 0, | |
]; | |
$output = '<style> .polylang_langswitcher {margin:0; list-style:none;} | |
.polylang_langswitcher li {display:inline-block; float:none; margin-left:0px;} | |
.polylang_langswitcher li:not(:last-child) {margin-right:20px;} | |
.polylang_langswitcher li a span {margin-left:0em !important;} | |
</style> | |
<ul class="polylang_langswitcher">'.pll_the_languages( $args ). '</ul>'; | |
} | |
return $output; | |
} | |
add_shortcode( 'polylang_langswitcher', 'custom_polylang_langswitcher' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment