Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
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.
Solved! Go to the solution
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 -%}
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. 🙂
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?
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.
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 -%}
Thank you Its working.
@MarinaPetrovic i was looking for this exact solution - this solved it beautifully. Thank you for the help. @Wayne18 thanks for posting this scenario - 🙂
Glad I could help! 😊
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.
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.
There is a better solution that does not require modifying the theme files.
Edit the collection's Publishing setting and unselect Online Store.
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.
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!
Hi, Can your code use as much as I want? it only worked for one collection and it didn't work for other collections
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 -%}
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!
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.
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!
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 %}
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!
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 %}
>
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...
As 2024 wraps up, the dropshipping landscape is already shifting towards 2025's trends....
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024In today’s interview, we sat down with @BSS-Commerce to discuss practical strategies f...
By JasonH Nov 13, 2024