EgeQW
November 26, 2023, 7:27pm
1
Hello, i was changing headers for diffrent pages in my “DAWN” theme website.
That was my code:
{% if template contains 'products' %}
<style>
sticky-header,header {
background-color: white !important;
position: static !important;
}
.header__menu-item {
color: black !important;
}
.header__icon {
color: black !important;
}
.header__active-menu-item {
color: black !important;
}
</style>
{%endif%}
But it just changes www.example.com/products
and i was looking for change www.example.com/products /product1, www.example.com/products /product2
Can someone help?
Thanks..
Hi @EgeQW
Do you mean want to change header for special products?
Please update if condition to this
{% if product.handle == 'product1' or product.handle == 'product2' %}
You also can use product ID instead of
{% if product.id == your-product1-id or product.handle == your-product2-id %}
EgeQW
November 27, 2023, 9:52am
3
Hello, i am not talking about special product. I have like 35 Product in my page and i will add more so i can’t change header one by one. So i need change all product’s header with one code.
So you correct is correct, it will add code if it is product page only
EgeQW
November 27, 2023, 10:13am
5
Yea but i am not trying add code to product page only, special product links but every product link at the one code.. Can’t i explain myself?
Example one code affect all special product pages..
EgeQW
November 27, 2023, 10:15am
6
I just don’t want place all product id’s or handles. Isn’t there any easier way.
You don’t need to add ID or handle, your code works for all product pages
{% if template contains 'products' %}
EgeQW
November 27, 2023, 10:38pm
8
Sir it’s already
{% if template contains 'products' %}
{%endif%}
like that but it wont affect product’s page it affect just site.com/products not site.com/product/producthandle
Hi, please try to update your code to this
{%- if template.name == 'product' -%}
{%- endif -%}
1 Like