How to display specific announcement bars on one page only?

AI-generated summary

Goal: show two specific announcement bars only on a single collection page, not sitewide.

  • Context: The target page is the “deodorizing-powder” collection. Initial bars appeared on all pages.
  • Solution: Add a Liquid conditional in theme.liquid (after the tag) keyed to collection.handle (‘deodorizing-powder’) so the target bars only render on that collection (and/or are hidden elsewhere). Initial attempt showed code on the homepage; after correcting the snippet to a proper Liquid conditional, placement either directly after or on a new line worked.
  • Outcome: Original poster confirmed the fix works.

Notes:

  • Liquid is Shopify’s templating language. collection.handle is the URL-friendly identifier for a collection. Screenshots were shared but not essential to understand the fix.

Open item:

  • A follow-up asks if the same logic can make a “wholesale” announcement appear only on the wholesale collection while suppressing general announcements on that collection. The user provided a sample conditional for handle ‘wholesale-items’. No answer yet; discussion remains open for this extension.

i have 2 announcements bars i made that i only want on 1 specific page but it is showing on all my pages. can anyone help with this?

Hi @ScentedCozy
Could you drop your store URL and the page URL that you want announcement bar appear?

store: https://scentedcozyco.com/

page i want it on : https://scentedcozyco.com/collections/deodorizing-powder

the 2 pink ones are what i want only on the attached page. all other announcement bars are fine as is.

Go to Online store > Themes > Edit code, open theme.liquid file, add this code after tag

{% if collection.handle != 'deodorizing-powder' %}
#shopify-section-sections--21674540335406__cfbc8c96-fb81-492e-b46c-18a8d8c0c42f,
#shopify-section-sections--21674540335406__8241898b-16d2-4d5b-8944-176a207060a9 {
display: none !important;
}
{% endif %}

here? right after head and before <Meta?

Yes, it correct

that did not work and it also added this to the top of my home page.

My mistake, please update code to this

{% if collection.handle != 'deodorizing-powder' %}

{% endif %}

just to be clear, do i hit enter to start a new line or add it directly after

Both will work

thank you! worked great!

You are most welcome.

Hi @Dan-From-Ryviu ,

I’ve been playing around with this. But I wonder if it’s possible to use this type of coding to restrict one announcement to one collection while also not allowing the general announcements to show on that one collection?

For example, I have a retail shop with one wholesale collection. I want only the wholesale announcement to show on that collection, but not anywhere else.

Thanks in advance for any help:)

Leila

https://leilacools.com/

{% if collection.handle != ‘wholesale-items’ %}

{% endif %}