We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

How to set filtering & sorting accordions closed as default?

Solved

How to set filtering & sorting accordions closed as default?

HBaars
Tourist
5 0 1

Filtering & Sorting accordions are all open as default when page loads. With so many filtering options, I'm trying to close all the accordions for people to then click on and discover further.

 

Using Tinker 1.0.5

Accepted Solution (1)

WebDeskSolution
Shopify Partner
252 55 64

This is an accepted solution.

Hello @HBaars 

 

Please follow the steps below after logging into the Shopify admin:

 

  • Go to your Shopify Admin panel.

 

 

  • Click on Online Store > Themes.
  • Find the theme you want to edit and then click Actions > Edit code.
  • Search theme.liquid

Insert the provided Script code at the above of the closing of the body(</body>) tag
SS : https://prnt.sc/_D8KD40wFkJK

 

<script>
      window.addEventListener('DOMContentLoaded', function() {
          const facetPanels = document.querySelectorAll('.facets__panel');
          facetPanels.forEach(function(panel) {
              if (panel.hasAttribute('open')) {
                  panel.removeAttribute('open');
              }
          });
      });
</script>

 

Please hit Like and Mark it as a Solution if you find our reply helpful.

Thank You,


WebDesk Solution Support Team
Get a Free Quote | Email | Shopify Partner | Shopify Development Agency | Call: 877.536.3789


Canada: 150 King St W. STE 200, Toronto, ON M5H 1J9

 | USA: 98 Cutter Mill Rd. STE 466, Great Neck, NY 11021

View solution in original post

Replies 4 (4)

jakeclifford
Shopify Partner
93 18 25

Hi @HBaars,


Can you send through a screenshot so I can see what you see?

Thank,
Jake 

I'm Jake the Shopify Wizard! If helpful Like and Mark as an Accepted Solution
My Blog - Tips and Tricks for Shopify Horizon and AI features Horizon + AI

Struggling to solve an annoying issue? Get Help Fast

WebDeskSolution
Shopify Partner
252 55 64

This is an accepted solution.

Hello @HBaars 

 

Please follow the steps below after logging into the Shopify admin:

 

  • Go to your Shopify Admin panel.

 

 

  • Click on Online Store > Themes.
  • Find the theme you want to edit and then click Actions > Edit code.
  • Search theme.liquid

Insert the provided Script code at the above of the closing of the body(</body>) tag
SS : https://prnt.sc/_D8KD40wFkJK

 

<script>
      window.addEventListener('DOMContentLoaded', function() {
          const facetPanels = document.querySelectorAll('.facets__panel');
          facetPanels.forEach(function(panel) {
              if (panel.hasAttribute('open')) {
                  panel.removeAttribute('open');
              }
          });
      });
</script>

 

Please hit Like and Mark it as a Solution if you find our reply helpful.

Thank You,


WebDesk Solution Support Team
Get a Free Quote | Email | Shopify Partner | Shopify Development Agency | Call: 877.536.3789


Canada: 150 King St W. STE 200, Toronto, ON M5H 1J9

 | USA: 98 Cutter Mill Rd. STE 466, Great Neck, NY 11021

HBaars
Tourist
5 0 1

This worked perfectly - thank you!

WebDeskSolution
Shopify Partner
252 55 64

Hello @HBaars 

 

Glad to hear that! Happy to help 😊

Thank You,


WebDesk Solution Support Team
Get a Free Quote | Email | Shopify Partner | Shopify Development Agency | Call: 877.536.3789


Canada: 150 King St W. STE 200, Toronto, ON M5H 1J9

 | USA: 98 Cutter Mill Rd. STE 466, Great Neck, NY 11021