How to restrict announcement bar display to certain pages? DAWN Theme

Topic summary

A user seeks code to display an announcement bar only on product pages, collection pages, and the cart page while hiding it elsewhere on their Dawn theme site.

Context:

  • Previous attempts with different code solutions and Shopify support chat have failed
  • Currently using Pop Convert app for one banner, but needs a second announcement bar (app limited to one banner)

Proposed Solution:
Another user provided Liquid code to add before the closing </body> tag in theme.liquid:

  • Uses {% unless %} conditional logic to hide content when template contains ‘product’, ‘collection’, or equals ‘cart’
  • Requires inserting announcement bar code between the unless tags

Status: Solution offered but not yet confirmed as tested or working by the original poster.

Summarized with AI on October 29. AI used: claude-sonnet-4-5-20250929.

Hi,

Can someone help me with some code for displaying my announcement bar only on my product pages, collection pages, and the cart page, but no where else on my site? I have tried some different code options and checked with the Shopify help chat but none of those solutions have worked.

I have one banner I am already using through the Pop Convert app, but I need to add an additional announcement bar and the app only allows one banner at a time.

Thanks for any help!

wildcoffee.co

Go to your online store → edit code → theme.liquid file and before closing tag paste this code

{% unless template contains 'product' or template contains 'collection' or template == 'cart' %}
  
{% endunless %}