[Resolved] Generatepress Hooks to add WPML menu switcher next to Toggle on mobile

Home Forums Support [Resolved] Generatepress Hooks to add WPML menu switcher next to Toggle on mobile

Home Forums Support Generatepress Hooks to add WPML menu switcher next to Toggle on mobile

  • This topic has 11 replies, 4 voices, and was last updated 1 year ago by Ying.
Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #1925244
    anabella

    On my website, I am using WPML and I have the language switcher (flags) in the main menu (it’s the last item in the menu).
    On desktop it looks great, but on mobile I would like to have the language switcher NEXT TO the toggle (instead of INSIDE the menu).

    Through WPML I can create a language switcher to display in custom locations (https://wpml.org/documentation/getting-started-guide/language-setup/language-switcher-options/#custom-locations), so I am trying to use Generatepress Hooks to add that code next to the Toggle, but it’s not working so I guess I’m doing something wrong.

    This is what I did:
    – I went to Elements > Hook
    – This is the code I added <?php do_action(‘wpml_add_language_selector’); ?>
    – Settings > Hook: I am lost here. I see the “Navigation” option with many options inside (generate_inside_navigation, generate_primary_menu, etc). I tried a few but couldn’t make it work so far

    COuld you please let me know?
    Thanks a lot in advance.

    #1925322
    David
    Staff
    Customer Support

    Hi there,

    check the Customizer > General >> Structure is set to Flexbox.
    Then you can use generate_menu_bar_items hook which is in the Primary Nav and Mobile Header ( if enabled ) and it will output beside the Search / Hamburger icons respectively.

    #1925350
    anabella

    Hi David,

    I followed those steps but unfortunately it’s not working.

    Any thoughts?
    Thanks

    #1925435
    David
    Staff
    Customer Support

    Can you share a link to the site ?

    #1925453
    anabella

    Hi David,

    I’m sharing the link through the Private Information box.
    For now, while I am running tests, I´ve applied the Hook only to this specific URL that I am sharing (the page is called Press), so it’s not applied to the entire site

    thanks

    #1925881
    Leo
    Staff
    Customer Support
    #1925929
    anabella

    Hi Leo,

    Yes, I’ve done everything David mentioned.
    I am sharing screenshots. Please see the URL that I am sharing in Private

    Thanks

    #1925956
    Leo
    Staff
    Customer Support

    Since you are adding PHP code, you will need to check the Execute PHP box.

    It’s currently blocked because of this:
    https://docs.generatepress.com/article/disallow-php-execution/

    #1925995
    anabella

    thanks Leo! I adjusted that, executed the PHP and now it’s working, but only on desktop. Not working on mobile

    #1926015
    Ying
    Staff
    Customer Support

    Hi there,

    The switcher has a ul element which will be hidden on mobile by default.

    Try add this CSS to override it:

    .main-navigation .menu-bar-items .wpml-ls-statics-shortcode_actions ul {
        display: flex;
    }
    #1926024
    anabella

    Thanks a lot, Ying! This worked 🙂

    #1926030
    Ying
    Staff
    Customer Support

    Glad to hear that 🙂

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