- This topic has 11 replies, 4 voices, and was last updated 4 years, 7 months ago by
Ying.
-
AuthorPosts
-
September 10, 2021 at 2:33 am #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 farCOuld you please let me know?
Thanks a lot in advance.September 10, 2021 at 4:03 am #1925322David
StaffCustomer SupportHi there,
check the Customizer > General >> Structure is set to Flexbox.
Then you can usegenerate_menu_bar_itemshook which is in the Primary Nav and Mobile Header ( if enabled ) and it will output beside the Search / Hamburger icons respectively.September 10, 2021 at 4:37 am #1925350anabella
Hi David,
I followed those steps but unfortunately it’s not working.
Any thoughts?
ThanksSeptember 10, 2021 at 5:48 am #1925435David
StaffCustomer SupportCan you share a link to the site ?
September 10, 2021 at 6:06 am #1925453anabella
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 sitethanks
September 10, 2021 at 8:21 am #1925881Leo
StaffCustomer SupportI don’t see David’s method above being applied currently:
https://generatepress.com/forums/topic/generatepress-hooks-to-add-wpml-menu-switcher-next-to-toggle-on-mobile/#post-1925322Can you confirm?
September 10, 2021 at 8:47 am #1925929anabella
Hi Leo,
Yes, I’ve done everything David mentioned.
I am sharing screenshots. Please see the URL that I am sharing in PrivateThanks
September 10, 2021 at 9:08 am #1925956Leo
StaffCustomer SupportSince 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/September 10, 2021 at 9:30 am #1925995anabella
thanks Leo! I adjusted that, executed the PHP and now it’s working, but only on desktop. Not working on mobile
September 10, 2021 at 9:38 am #1926015Ying
StaffCustomer SupportHi there,
The switcher has a
ulelement 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; }September 10, 2021 at 9:41 am #1926024anabella
Thanks a lot, Ying! This worked 🙂
September 10, 2021 at 9:45 am #1926030Ying
StaffCustomer SupportGlad to hear that 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.