Last active
November 1, 2023 07:55
-
-
Save taninbkk/f95281b44b3762435777 to your computer and use it in GitHub Desktop.
Polylang Shortcode
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
// Polylang Shortcode - https://wordpress.org/plugins/polylang/ | |
// Add this code in your functions.php | |
// Put shortcode [polylang] to post/page for display flags | |
function polylang_shortcode() { | |
ob_start(); | |
pll_the_languages(array('show_flags'=>1,'show_names'=>0)); | |
$flags = ob_get_clean(); | |
return $flags; | |
} | |
add_shortcode( 'polylang', 'polylang_shortcode' ); |
Thanks a bunch for this!
Any guess on how to style the dropdown arrow for this? Im trying to replace it with a custom svg, but I couldnt get it with the one i targeted the rest of the menu drop-downs.
.et-menu .menu-item-has-children>a:first-child:after{ content: url(/dropdownarrow.svg); }
I couldnt get the target with inspect and was unable to find it in the plugin files (although im sure it is in there somewhere).
How to set user wise [POLYLANG] in wordpress?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hiding the current language flag is possible with 'hide_current' =>1 in the above array:
pll_the_languages(array('show_flags'=>1,'show_names'=>0,'hide_current'=>1'));
All possible elements of the language switcher array can be found in plugins/polylang/include/switcher.php right at the beginning of the file (Polylang v3.1.4).