• I use polylang plugin as the multilanguage solution for my website.

    In my menu I use the polylang widget with Elementor builder. In the classic polylang menu made in your wordpress you could add polylang widget switcher where you could choose the option to display flags only. Problem is that I don’t use menu widget switcher because I don’t want to display switcher with the menu items but in my custom column of my header.

    I use the Elementor’s widget which is used in sidebars. But sidebar widget switcher does not have the option to display flags only in a dropdown menu. It displays only the language names with no option to display flags. What I need to do is to display flags only in my custom widget.

    I have also tried this code to try with a shortcode but it is also showing only the language names and not flags.

    function custom_polylang_langswitcher() {
        $output = '';
        if ( function_exists( 'pll_the_languages' ) ) {
            $args   = [
                'show_flags' => 1,
                'show_names' => 0,
                'echo'       => 0,
                'dropdown'   => 1,
            ];
            $output = '<ul class="polylang_langswitcher">'.pll_the_languages( $args ). '</ul>';
        }
    
        return $output;
    }
    
    add_shortcode( 'polylang_langswitcher', 'custom_polylang_langswitcher' );

    Thanks in advance for your help

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter mikel555

    (@mikel555)

    Any response please? ??

    • This reply was modified 3 years, 7 months ago by mikel555.

    I really which that Polylang works on a solution for that too.
    Personally, I am not a fan of associating a “flag” to a “language” (it makes no sense for me) but some clients insists…

    Other tools do it, why not my beloved Polylang?

    Plugin Author Chouby

    (@chouby)

    Hello,

    Other tools do it, why not my beloved Polylang?

    The dropdown language switcher in the widget is a ‘<select>’ html element. This doesn’t accept images but only text. When you see a dropdown with images, this is obtained with javascript code.
    1. I don’t want Polylang to output javascript on frontend.
    2. Even if we create such dropdown with Javascript, it’s very likely that your theme will not style it correctly (as this would not be obtained with a standard html element known by the theme but with custom js). So this would require frontend dev competence to be styled. I prefer not to have features requiring such competence to be used.

    Thanks for your reply @chouby
    I understand the “why not include that by default”.

    But it will be nice to provide the option too or at least a code snippet for people who wants that option. Just said it’s for advanced users and that no support will be provided on that topic as it requires custom coding.

    I think that dropdowns for languages WITH flags is a common thing and it’s a bit sad that Polylang doesn’t help in any ways to achieve this.

    Hi, I found a simple solution!
    I just added emoji flags instead the plugin flags.
    Works like a charm and you still have more options like for example, european flag!

    @inkedbooking gosh, you’re smart ! thanks ??

    Thread Starter mikel555

    (@mikel555)

    @inkedbooking wow, I will try! Thank you

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Language dropdown switcher with flags only in widget’ is closed to new replies.