Skip to content

Instantly share code, notes, and snippets.

@nicomollet
Last active June 24, 2024 21:16
Show Gist options
  • Save nicomollet/47ba9808f3187c9f1568d8f7c4355b54 to your computer and use it in GitHub Desktop.
Save nicomollet/47ba9808f3187c9f1568d8f7c4355b54 to your computer and use it in GitHub Desktop.
Polylang shortcode for lang switcher
<?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' );
@descrop
Copy link

descrop commented Apr 3, 2023

CSS para mostrar las banderas en línea y sin viñetas, el relleno es solo para agregar espacio entre los elementos.

CSS to display the flags inline and without bullets, the padding is just to add space between elements.

.lang-item{
display:inline;
padding-left:5px;
list-style:none;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment