How do I hide a collection from the collection list with the Dawn theme?

Solved

How do I hide a collection from the collection list with the Dawn theme?

Wayne18
Tourist
11 0 1

Hello:
I want to hide a specific collection from the collection list but the collection page itself can still be visible and accessible through URL. I've seen many solutions online but none of them is for the Dawn theme and Dawn theme's code editor is different from the others. Here's the link: https://www.unidshop.com/collections/

 

Basically I want the collection without a proper icon to be invisible yet can still be accessed by customers with a link. Changing it's availability would make in completely inaccessible to even myself, so that won't work. Is there any way to do that?

 

Thanks to anyone for their help.

Accepted Solution (1)
MarinaPetrovic
Shopify Partner
559 124 191

This is an accepted solution.

Hi @Wayne18 , when you add a new collection you should just add it like this to the existing code:

{%- for collection in collections -%}
{% if collection.handle == "cherry-offer" or collection.handle == "YOUR-NEW-COLLECTION" %}
{% else %}
      <li class="collection-list__item grid__item">
      {% render 'card-collection', card_collection: collection, media_aspect_ratio: section.settings.image_ratio, columns: 3 %}
      </li>
{% endif %}
{%- endfor -%}
M.Petrovic | Shopify Developer
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution

View solution in original post

Replies 22 (22)

MarinaPetrovic
Shopify Partner
559 124 191

Hi @Wayne18 , go to edit code > sections > main-list-collections.
Find this part:

{%- for collection in collections -%}
        <li class="collection-list__item grid__item">
          {% render 'card-collection', card_collection: collection, media_aspect_ratio: section.settings.image_ratio, columns: 3 %}
        </li>
      {%- endfor -%}

 

And replace it with:

{%- for collection in collections -%}
{% if collection.handle == "cherry-offer" %}
{% else %}
      <li class="collection-list__item grid__item">
      {% render 'card-collection', card_collection: collection, media_aspect_ratio: section.settings.image_ratio, columns: 3 %}
      </li>
{% endif %}
{%- endfor -%}

 

I suppose that you're talking about 'cherry-offer' - code above will hide it from collection list page. 🙂



M.Petrovic | Shopify Developer
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
Wayne18
Tourist
11 0 1

@MarinaPetrovic 

It worked. Thank you!

So what if I have to create new collections in the future and want to hide them as well? Do I need to put the name of the collection in the same line of codes or create a new line of codes with the collection name?

Wayne18
Tourist
11 0 1

@MarinaPetrovic 

Please answer. I will have to make more collections in the future and I need to know now how to hide more than one collection at once. Thank you.

MarinaPetrovic
Shopify Partner
559 124 191

This is an accepted solution.

Hi @Wayne18 , when you add a new collection you should just add it like this to the existing code:

{%- for collection in collections -%}
{% if collection.handle == "cherry-offer" or collection.handle == "YOUR-NEW-COLLECTION" %}
{% else %}
      <li class="collection-list__item grid__item">
      {% render 'card-collection', card_collection: collection, media_aspect_ratio: section.settings.image_ratio, columns: 3 %}
      </li>
{% endif %}
{%- endfor -%}
M.Petrovic | Shopify Developer
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
Wayne18
Tourist
11 0 1

@MarinaPetrovic 

Thank you so much!

ShreyaModia
Tourist
3 0 1

Thank you Its working.

Caidra
Excursionist
40 1 10

@MarinaPetrovic i was looking for this exact solution  - this solved it beautifully. Thank you for the help. @Wayne18 thanks for posting this scenario - 🙂

MarinaPetrovic
Shopify Partner
559 124 191

Glad I could help! 😊

M.Petrovic | Shopify Developer
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
Daddidio
Visitor
2 0 0

Thanks so much! This is what I also needed.  I also want the products in this collection to not show in the all products list.  I'm still looking for that.  Please let me know if you've already solved this.

Daddidio
Visitor
2 0 0

Actually not working for me.  Code saves correctly.  Even a simple change to the number of columns doesn't work for me.  Thanks anyway.  I'll keep looking. 

EdLazor
Excursionist
21 0 7

There is a better solution that does not require modifying the theme files.

 

Edit the collection's Publishing setting and unselect Online Store.

TWCIndia
Tourist
14 0 3

Hi

 

I want to hide certain collections from collections list page. But want them to be visible when someone has a link. How do I do that in Dawn theme? Can you please send me the exact code that needs to be put and where? 

 

I don't understand the cherry-offer thingy above. 

BelK-AWCC
Tourist
6 0 1

Hi, 

I'm looking to do the same but am using the 'Trade' theme. Wondering if someone could correct my code? I added in lines 32/33 per Marina's example above, and then closed the with endif in line 39.  The remainder of code is as per the default.
This hasn't worked and my 2x categories are both still showing in my category list. 
I use the categories on my home page, but I don't want them to show up as actual categories when shoppers are browsing. 
Attached pics for reference if anyone could please assist!

Screenshot 2024-09-26 at 12.18.37 AM.png

Thusithaja
Shopify Partner
16 0 1

Hi, Can your code use as much as I want?  it only worked for one collection and it didn't work for other collections 

Caidra
Excursionist
40 1 10

yes it works for multiple collections - refer to the second code shared by @MarinaPetrovic 

{%- for collection in collections -%}
{% if collection.handle == "cherry-offer" or collection.handle == "YOUR-NEW-COLLECTION" %}
{% else %}
<li class="collection-list__item grid__item">
{% render 'card-collection', card_collection: collection, media_aspect_ratio: section.settings.image_ratio, columns: 3 %}
</li>
{% endif %}
{%- endfor -%}

 

robin87
Tourist
11 0 2

Hello! I think this may be the solution I'm looking for, but the code I'm working with is slightly different so it won't accept the changes. Here is the code I'm working with that appears to be the closest to your example:

 

 {% for collection in collections %}
              {% render 'collection-block', collection: collection, custom_aspect_ratio: chosen_aspect_ratio, animate: true %}
            {% endfor %}
          </div>
        </div>

        <div class="pagination-row" data-cc-animate>{% render 'pagination-control', paginate: paginate %}</div>
      {% endpaginate %}

    {% else %}

Will this fix still work for me with some adjustments? 

 

Thanks so much!

Caidra
Excursionist
40 1 10

Hi robin
Are you working on the sections > main-list-collections file? If yes, just copy Marina's code and then insert the names of your collection that you wish to hide within "".  See screenshot from my code below for reference. I have hidden multiple collections. Point to note is that the name of the collection needs to be copied from the URL as it may be different to the display name.

Caidra_0-1680609561229.png

 

robin87
Tourist
11 0 2

Thank you for responding! I am working on sections > main-list-collections file, but my code looks a little different. I feel like I'm probably just pasting the code in the wrong place as a result - I don't really know much HTML but I know enough to know something isn't right lol. Here's a screenshot of the code I'm working with. Thanks for your help!

 

for-collection-in-collections.jpg

MarinaPetrovic
Shopify Partner
559 124 191

Hi @robin87 , can you explain what exactly do you want to achieve? If you'd just like to hide some of the collections, replace this:

 {% for collection in collections %}
              {% render 'collection-block', collection: collection, custom_aspect_ratio: chosen_aspect_ratio, animate: true %}
            {% endfor %}

with:

{% for collection in collections %}
{% if collection.handle == "YOUR_COLLECTION_HANDLE" %}
{% else %}
 {% render 'collection-block', collection: collection, custom_aspect_ratio: chosen_aspect_ratio, animate: true %}
{% endif %}
{% endfor %}
M.Petrovic | Shopify Developer
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
robin87
Tourist
11 0 2

Ok well I'm definitely having a "my car is making a noise, I swear!" moment, because I just got it to work lol thank you all for your patience with me! This is a really helpful little trick and I'll be making good use of it!

JacJacC
Excursionist
42 0 9

Hi All,

 

My code is not the same as your, i tried to amend the code but it was getting worst, can anyone help on this? I just want to hide the collection on the collection list, but keep on showing it in the home page, can one can help? my code is like below.....

 

 

{%- for collection in collections -%}
<li
class="collection-list__item grid__item{% if settings.animations_reveal_on_scroll %} scroll-trigger animate--slide-in{% endif %}"
{% if settings.animations_reveal_on_scroll %}
data-cascade
style="--animation-order: {{ forloop.index }};"
{% endif %}
>

pzs111111
Visitor
1 0 0

JacJacC,

 

Try adding the following after {%- for collection in collections -%}:

        {% if collection.handle == "frontpage" %}
          {%- continue -%} {# Skip rendering this collection #}
        {% else %}

 I had the exactly the same codes as yours, but these codes worked. ChatGPT could be something solid...