Set any "Sort By" as default on collections page

By default, Shopify lets users sort products in a collection, but it doesn’t give you much control over the initial sort order that customers see when they first land on your collection page. That’s where this simple code snippet comes in.
In this tutorial, you’ll learn how to set a custom default filter for your product collections — whether you want to highlight your newest arrivals, best-sellers, or most expensive items first, all of that just by installing our EZFY's Instant Collection Filter! By pasting a little bit of code and learning how to change a single key value, you will soon be guiding your visitors’ shopping experience from the moment they arrive. Let’s get started!
Before starting the tutorial, click here to download the code.
This tutorial is compatible only with Shopify's official free themes: Colorblock, Craft, Crave, Dawn, Origin, Publisher, Refresh, Ride, Sense, Spotlight, Studio, Taste & Trade.
Looking to install this on a premium or custom theme? Feel free to contact us.
Step 1: creating the snippet file
- From your Shopify admin, go to Online Store > Themes > ... > Edit Code.
- In the left sidebar, scroll down and click on the Snippets folder. At the top of the Snippets folder, click Add a new snippet. In the popup that appears:
- Make sure the file type is set to Liquid.
- Name the file exactly ezfy-instant-collection-filter.
- Click Done.
- Now open the file you downloaded from the link above and copy all of its content. Paste the code inside the ezfy-instant-collection-filter.liquid file you just created, then click Save in the top right corner.
Step 2: adding the snippet to your collection page
- In the code editor sidebar, use the search bar to find the main-collection-product-grid.liquid file in the Sections folder and open it.
- Inside it, use CTRL + F (or Command + F on Mac) to search for the line of code that says </select>. Clicking the Next button will take you to it.
- In the very next line before any other code, paste the following:
{% render 'ezfy-instant-collection-filter' %}
Hit the Save button and you're done with the installation! Let's learn how to use the filter and test it out next.
Step 3: testing your filter
-
Go back to the ezfy-instant-collection-filter.liquid file and you'll see the following right at the start:
- Pick the new default filter order you would like to use from the list, copy the bit before the arrow (the first two words connected by a -), and paste it in place of the underlined area below, making sure it's between quotes (').
- For example, assuming you want to order your products by price starting from the highest, line 19 in the picture shown would read const SORT_BY = `price-descending`.trim();
- Let's see it in practice! Here's what it looks like using the default 'created descending' option, using our own ezfycode.com page as a showcase:
But after you replace that bit of text, it looks like this:
Note how the order of the products changed. Of course your visitors can still sort out the display order based on what they're looking for, but now they'll see what you want to show right away without having to click a thing!
Conclusion
And that’s it — you’ve successfully customized your Shopify collection page to display products in the default order you choose. This small tweak can have a big impact on user experience and sales by strategically highlighting your newest, most popular, or highest-margin products first. Best of all, it’s easy to change later if your priorities shift.
With your custom filter in place, you’re giving your store a more curated, intentional feel — and making it easier for customers to discover the products that matter most. Happy selling!