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.
Tagged: Exception
This topic contains 3 replies, has 3 voices.
Last updated by Prosenjit Barman 1 year, 3 months ago.
Assisted by: Prosenjit Barman.
Author | Posts |
---|---|
September 29, 2023 at 5:57 am #14485473 | |
arnoP-3 |
Hi, I have a few post types (bbPress threads, forums, etc.) that are non-translatable. I would expect the WPML language switch to remain available and simply switch to the homepage of the non-available language if it is selected, just like it does on a translatable post that is not translated. However, it looks like WPML practice is to hide the switcher on non-translatable post types. That is ok as well, although it does make pages less consistent in their look and feel. But now I found that the switcher is still rendered in HTML, except that there are no drop-down values. Because of the custom styles we applied to the switcher, it now shows a gray line on the non-translatable posts. Please see attached. How can I prevent the switcher from being rendered? If it's not going to show anything then there is no reason for the HTML to even be there. Or worst case, how do I hide it using CSS? Thanks, |
October 1, 2023 at 9:35 am #14492705 | |
Christopher Amirian Supporter
Languages: English (English ) Timezone: Asia/Yerevan (GMT+04:00) |
Hi Arno, I will add the first reply before this ticket is assigned to one of my colleagues. There is no option to hide the language switcher selectively. The only option available is to skip a language or not that you can find in: WordPress Dashboard > WPML > Languages > Language switcher options For a CSS solution please give us a link to the page that has the issue that you described and we might be able to see if the specific custom post type slug is added as an HTML class in the BODY tag or not. If yes, we might be able to hide it if needed. Thanks. |
October 1, 2023 at 9:49 am #14492745 | |
arnoP-3 |
Hi Christopher, Here are some example pages: So, it's by design that the language switcher always renders, but as an empty dropdown if there are no alternative languages? I tried "Skip language" instead of "Link to home of language for missing translations" but that doesn't make a difference. Thanks, |
October 2, 2023 at 7:17 am #14494865 | |
Prosenjit Barman Supporter
Languages: English (English ) Timezone: Asia/Dhaka (GMT+06:00) |
Hello Arno, Thanks for providing the links. It's important to note that when you add a Block widget, the corresponding HTML markups will always render on the front end. As you've implemented the Language Switcher Block widget in the Footer, its markup is rendering on the frontend, which is expected, even though there's no translation available for that page. However, if you navigate to "WPML > Languages" and scroll down, you'll find three ways to add a language switcher to your site. When you implement a language switcher using any of these ways, the HTML markups won't appear if the page hasn't been translated. Just make sure that the `current language` is not selected to appear in the language switcher. Please check this documentation for more information: https://wpml.org/documentation/getting-started-guide/language-setup/language-switcher-options/#add-a-language-switcher-to-a-menu-footer-or-widget I hope I'm able to clarify things for you. But, if you need further assistance or clarification, feel free to reach out. I will be happy to help. Best Regards, |
October 2, 2023 at 9:22 am #14496367 | |
arnoP-3 |
Thanks Prosenjit. I opted for a text link instead of a dropdown, and that renders only when it needs to. |