[Resolved] Polylang language switcher

Home Forums Support Polylang language switcher

  • This topic has 8 replies, 2 voices, and was last updated 7 months ago by David.
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #1207309
    Martin K Lønne

    Hi!
    We have the GP premium upgrade and are wondering if there is a PHP hook to add the Polylang menu switcher as a wordpress menu item? So it is integrated in the menu, and not in the header.

    #1207551
    David
    Staff
    Customer Support

    Hi there,

    you can add it inside the navigation container using this hook:

    https://docs.generatepress.com/article/generate_inside_navigation/

    If you can share a link to your site with it in place i can assist with the CSS for aligning it.

    #1208158
    Martin K Lønne

    Hi!
    Here is the url:
    emmany.wpengine.com

    It is wanted at the end of the navigation like this:

    #1208217
    David
    Staff
    Customer Support

    Try this CSS:

    @media (min-width: 769px) {
        .inside-navigation {
            display: flex;
            align-items: center;
            flex-direction: row-reverse;
        }
    }
    #1208306
    Martin K Lønne

    Nice solution! Did not think about row-reverse. How about mobile layout? is there another hook for mobile menu?

    #1208310
    David
    Staff
    Customer Support

    For the Mobile header there is inside_mobile_header or you could just disable the Mobile Header.

    #1208332
    Martin K Lønne

    Hi!
    If you check the link again, the hook does not work correctly for the mobile menu.

    function addLanguageSwitcher() {
    	pll_the_languages(array('dropdown'=>1)); 
    }
    
    add_action( 'generate_inside_navigation', 'addLanguageSwitcher');
    add_action( 'inside_mobile_header', 'addLanguageSwitcher');
    #1208337
    Martin K Lønne

    Solved this, seems polylang has a quite hidden option to simple add the language switcher as a menu item.
    Thank you!

    #1208341
    David
    Staff
    Customer Support

    Awesome – thanks for letting us know.

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.