[Resolved] Language Switcher Gutenberg block not working
This thread is resolved. Here is a description of the problem and solution.
Problem: If you're using WPML with a custom FSE (Block) theme and notice that the dropdown CSS and JavaScript for the Language Switcher Gutenberg block are not being enqueued on the front page, even though they work in the Gutenberg editor. Solution: We recommend adding the following custom PHP code to your theme's
This code manually enqueues the necessary styles for the language switcher block. If this solution doesn't resolve your issue, please open a new support ticket with us.
This is the technical support forum for WPML - the multilingual WordPress plugin.
Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.
I am using WPML with a custom FSE (Block) theme. When I try to use a dropdown language switcher via the Language Switcher Gutenberg block, its dropdown css and javascript get enqueued and work in the Gutenberg editor, but don't get enqueued when the front page is rendered. This happens even if my custom theme has nothing at all in its functions.php.I'm looking at the source of sitepress-multilingual-cms, but could use some help figuring out why my theme doesn't want to enequeue the block assets.
I've installed the theme and the base Elementor plugin, as it's used on pages other than the front page and functions.php currently assumes it's installed. If you go into the Theme Editor and edit the front page, you'll see a dropdown Language Switcher just below the hero (image 1, shown hovered). But if you look at the rendered homepage at hidden link, you'll see it's displayed as a list (image 2). It appears that this is becauase the css and javascript for the language switcher block aren't being enqueued.
Thank you Kor, but I'm viewing it in a private window but not seeing any change on that page. I see a list of languages as shown in the earlier screenshot, but I would expect to see the language dropdown (because that's how the gutenberg block is configured). I checked the page source, and the dropdown css/js are still not being loaded on that page.
Are you seeing something different? Is there a cache that might need to be cleared?
I apologize for my mistake. I can see the issue now and please allow me to escalate this to our 2nd Tier Support for further assistance. I will come back to you once I have feedback.
Our 2nd Tier Support checked and this is a bug and a workaround to fix this would be to insert the custom PHP code below into your theme functions.php file .
Manually enqueueing the content worked, thank you!
Manage Cookie Consent
We use cookies to optimize our website and services. Your consent allows us to process data such as browsing behavior. Not consenting may affect some features.
Functional
Always active
Required for our website to operate and communicate correctly.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
We use these to analyze the statistics of our site. Collected information is completely anonymous.The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
These cookies track your browsing to provide ads relevant to you.