Is it possible to display a collection product count on a standard non-collection page

Topic summary

Goal: Show product counts for hard‑coded sub‑collection links on a template (non-dynamic blocks) and hide any sub‑collection with zero products.

Context/constraints:

  • Template lists a parent collection, then hard‑coded blocks for ~8 sub‑collections, then the parent’s products.
  • Because blocks aren’t dynamic, each sub‑collection must be referenced explicitly to test products_count.

Attempted approach (Liquid):

  • Tried assigning a collection handle and looping to check products_count > 0 before rendering a block.
  • Sample used: assign collections = ‘aerial-firefighting-ac313’; looped over collections; then accessed collection via collections[collection_handle]; expected an

    with collection.title when products_count > 0.

Outcome:

  • No output appeared, despite knowing the handle has 2 products.
  • Seeks reasons why the conditional didn’t pass and how to correctly reference the collection for the count.

Status:

  • Unresolved. Key needs: a reliable way to map each hard‑coded block to its collection object by handle and conditionally render based on products_count, plus clarification on why the provided code isn’t producing output.
Summarized with AI on December 23. AI used: gpt-5.

I have a page which contains hard coded collection links. Due to the complexity of the collection structure, they had to be hard coded inside a template. What I’d like to know is whether it’s possible to display the product count for a set collection on this page?

The current layout of the collection template looks something like this

Title

Blocks of sub-collections to further filter down (There are around 8 of these and are hard coded into a template)

List of products in the parent collection

Using the layout above as an example, in some cases I may only have 3 products in the entire parent collection. Meaning some of the sub-collections are going to be empty. What I’d like to be able to do is to hide some of these if their product count is empty. This is what I’m struggling with. I’ll need to wrap a conditional around every sub-collection block but I would need to somehow define or assign the collection in order to test the conditional. But because the blocks are not dynamic, they have no real ‘link’ to a collection.

Does anyone have any advice on what I could do here? Any help much appreciated.

Hello again,

Unfortunately I have not been able to get the code to display/no display what I need. I tried implementing the code you provided into one of my templates. To begin with I just tested the code isolated from the rest of the page as such

{% assign collections = ‘aerial-firefighting-ac313’ %}

{% for collection_handle in collections %}
{% assign collection = collections[collection_handle] %}

{% if collection.products_count > 0 %}

{{ collection.title }}

{% endif %} {% endfor %}

The only thing that’s different is that I have removed the array of handles in place of just one value; ‘aerial-firefighting-ac313’

I know by looking in the collections list that ‘aerial-firefighting-ac313’ has 2 products assigned to it.

So by that logic, the

title of the collection should display. Unfortunately it didn’t. Could there be something additional preventing this?