Change Default Filter In Shopify Theme

- 1 answer

This code is from shopify, however, I would like to know how to make the default sort option to be "Newest to Oldest", right now it is "A-Z". This is for a page that does not have a collection on it so it is not pulling from the option already selected on the collection page.

<div id="sort-by-menu">
  <label for="sort-by">Sort by</label> 
  <select id="sort-by">
    <option value="created-ascending">Oldest to Newest</option>
    <option value="created-descending">Newest to Oldest</option>
    <option value="best-selling">Best Selling</option>
    <option value="manual">Featured</option>
    <option value="price-ascending">Price: Low to High</option>
    <option value="price-descending">Price: High to Low</option>
    <option value="title-ascending">A-Z</option>
    <option value="title-descending">Z-A</option>

Shopify.queryParams = {};
if ( {
  for (var aKeyValue, i = 0, aCouples ='&'); i < aCouples.length; i++) {
    aKeyValue = aCouples[i].split('=');
    if (aKeyValue.length > 1) {
      Shopify.queryParams[decodeURIComponent(aKeyValue[0])] = decodeURIComponent(aKeyValue[1]);
  .val('{{ collection.sort_by | default: collection.default_sort_by | escape }}')
  .bind('change', function() {
    Shopify.queryParams.sort_by = jQuery(this).val(); = jQuery.param(Shopify.queryParams).replace(/\+/g, '%20');


If this is for the all products page

Simply change the link to

Also you can actually create a collection named "All" and control the sorting. Comment if you still have questions.