Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
The client wants to display an announcement bar only on the English version of their website using WPML and the Blocksy theme.
Solution:
We recommend creating the announcement bar block and assigning it a specific CSS class. Then, use CSS to hide this block from other languages. Here's a step-by-step guide:
1. Create the announcement bar in your Blocksy theme and assign a unique CSS class to it.
2. Use the following CSS rule to hide the block from other languages, replacing '

.your-css-class

' with the class you assigned:

.html:not(:lang(en)) .your-css-class { display: none; }

This CSS rule ensures that the announcement bar is only visible on the English version of your site.
For more details on CSS targeting based on language, you can refer to this Stack Overflow discussion: https://stackoverflow.com/questions/8916360/whats-the-difference-between-htmllang-en-and-htmllangen-in-css

If this solution does not apply to your case, or if it seems outdated, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If further assistance is needed, please open a new support ticket at WPML support forum.

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: 

This topic contains 1 reply, has 2 voices.

Last updated by Mihai Apetrei 10 months, 2 weeks ago.

Assisted by: Mihai Apetrei.

Author Posts
July 24, 2024 at 5:07 pm #15999742

markv-51

Background of the issue:
I want to show an announcement bar on our English website. I don't want the other language to show it. I usually create announcement bars with our theme (blocksy), but I am unsure how to make it only appear on one language.

Symptoms:
No specific issue or error message mentioned.

Questions:
How can I show an announcement bar only on the English version of my website using WPML?

July 24, 2024 at 7:17 pm #16000093

Mihai Apetrei
WPML Supporter since 03/2018

Languages: English (English )

Timezone: Europe/Bucharest (GMT+03:00)

Hi there.

One quick way that I'm thinking of is to create the block, give it a CSS class, and then use CSS to hide that from other languages.

I created a custom search URL for you so that you can quickly find examples:
hidden link

Also, here is an example on how to target the language code:
https://stackoverflow.com/questions/8916360/whats-the-difference-between-htmllang-en-and-htmllangen-in-css

I hope that you will find this information helpful. 🙂

Mihai Apetrei

July 24, 2024 at 7:52 pm #16000145

markv-51

Hi,

This indeed seems like a neat solution. Great idea, thank you!