Can't Add Fields to collections/all
The page at /collections/all Vs. Other Collections
Shopify differentiates the page at /collections/all
from all other collections. For this reason, Custom Fields needs to treat them differently as well. Shopify does not allow us to add fields to the special collection located on your site at yoursite.com/collections/all
.
In order to add fields to that page, you'll need to use a clever workaround.
No workaround is needed when adding fields to any other collection.
The Workaround for /collections/all
It's easiest to simply add one of the snippets below to your collections template which will handle printing of fields for both types of collections.
1.) Create a new collection in Shopify. You'll use this collection to attach your fields to, then reference that collection on /collections/all
so it looks like the fields are attached to that special collection.
2.) Add some fields to Collections in the app.
3.) Edit your template called collections.liquid using these snippets as a starting point.
{% comment %} EXAMPLE 1: In this example we print the field values directly. First, we test if we're on the special collection at collections/all. If we are, we print individual fields for the special collection directly, without using the Custom Fields include statement, for simplicity. Using this method you have the most flexibility, but if you add a field to your special collection you'll need to update your code here to print it out. Fields on other collections will still print automatically though. {% endcomment %} {% if collection.handle == 'all' %} {{ collections.YOUR-WORKAROUND-COLLECTION-HANDLE.metafields.custom_fields.YOURFIELD }} {% else %} {% include 'collections.custom_fields' %} {% endif %} {% comment %} EXAMPLE 2: In this example, we let Custom Fields print the fields for us. First, we test if we're on the special collection at collections/all. If we are, we do some manuvering to pass the collection in it's current state to the Custom Fields include statement, then assign the variable back for use in the rest of the template. Using this version, Custom Fields will always print any field you've configured, but you have less flexibility for display. {% endcomment %} {% if collection.handle == 'all' %} {% assign save = collection %} {% assign collection = collections.YOUR-WORKAROUND-COLLECTION-HANDLE %} {% include 'collections.custom_fields' %} {% assign collection = save %} {% else %} {% include 'collections.custom_fields' %} {% endif %}