Hide filter "Gender" from specific collection pages

Topic summary

A Shopify store owner using the Dawn theme needs to hide the “Gender” filter from four specific collection pages (menino-2-6-anos, menina-2-6-anos, rapaz-7-12-anos, and rapariga-7-12-anos).

Problem: Previously used code stopped working.

Solutions offered:

  • BSSCommerce-B2B provided corrected Liquid code using request.host and request.path to target specific URLs
  • Dan-From-Ryviu suggested an alternative approach using collection.handle

Resolution: The first solution from BSSCommerce-B2B successfully resolved the issue. The code checks if the current URL contains any of the specified collection handles and hides the gender filter accordingly using CSS display properties.

Summarized with AI on November 7. AI used: claude-sonnet-4-5-20250929.

Hello, I’m looking for a way to hide a specific filter (gender) from certain collection pages (menino-2-6-anos, menina-2-6-anos, rapaz-7-12-anos and rapariga-7-12-anos). I’m using Dawn theme and my website is petitfoxportugal.myshopify.com.

I once used the code below before the tag but it is not working now. How can I get it to work? Thanks!

{% assign full_url = request.host | append: request.path %}
{% if full_url contains 'menino-2-6-anos' or full_url contains 'menina-2-6-anos' or  full_url contains 'rapaz-7-12-anos' or full_url contains 'rapariga-7-12-anos' %}
<style>
.disclosure-has-popup:has(#Facet-1-template--23112144945501__product-grid) {
   display: none !important;
}
</style>
{% endif %}

Hi,

You can edit your code to look like this

{% assign full_url = request.host | append: request.path %}
{% if full_url contains 'menino-2-6-anos' or full_url contains 'menina-2-6-anos' or  full_url contains 'rapaz-7-12-anos' or full_url contains 'rapariga-7-12-anos' %}

{% endif %}

or

{% assign full_url = request.host | append: request.path %}
{% if full_url contains 'menino-2-6-anos' or full_url contains 'menina-2-6-anos' or  full_url contains 'rapaz-7-12-anos' or full_url contains 'rapariga-7-12-anos' %}

{% endif %}

If it helps you, please like and mark it as the solution.

Best Regards

1 Like

Hi @PetitFox

You can try to use this code and check

{% if collection.handle contains 'menino-2-6-anos' or collection.handle contains 'menina-2-6-anos' or  collection.handle contains 'rapaz-7-12-anos' or collection.handle contains 'rapariga-7-12-anos' %}

{% endif %}

Thanks! The first one worked :raising_hands: