Create your own ecommerce website and start selling successfully with ShopWired today

Create your ecommerce website on ShopWired today.
Start today with 14 days free

Create your own ecommerce website and start selling successfully with ShopWired today

Create your ecommerce website on ShopWired today.
Start today with 14 days free

Displaying products or sub-categories from a specific category

Theme Customisations - Coding
15th January 2021

Before you proceed:
The following article contains information that requires you to have some prior knowledge about coding in order to correctly implement the proposed change to your theme. If done incorrectly alterations made to your theme’s code can negatively impact your website causing visual and performance issues. Therefore, we strongly recommend that you only undertake this effort if you are completely confident that you know what you’re doing. If you have no coding experience at all, aren’t entirely comfortable following the instructions in this article or if you simply don’t understand the instructions then we recommend you instead contact our partners, Coding Masters, who will complete the work for you for a set fee.


There maybe times where, on a specific page, you would like to display the products or subcategories from a specific category.

For example, you may want to create a landing page on your website for a particular campaign and display the products belonging to a 'special offer' category.

In this guide, we've listed the necessary twig code that you'll need to use to do so.

Note: The guide assumes that you have already created the twig file that renders the page you are creating.


Firstly, you'll need the unique ID of the category whose products/subcategories you want to display. The ID can be located within the management system. When editing a category, your browser's address bar will display a URL like /business/manage-ecommerce-add-category/104729, the final number 104729 is the unique ID of the category.

On the twig page that you want to render the products/subcategories, you'll need to set the category as follows:

{% set your_category = category(104729) %}

The your_category variable can be given any name that you want. Replace the number shown above with the unique ID of your category.

Once you've done this, you'll have access to the category object of the set category, e.g.

{{ your_category.title }}

will return the name of the set category.

You now have access to the product object of every product that belongs to the set category, e.g.

{% for product in your_category.products %}
         {{ product.title }}
{% endfor %}

Similarly, you have access to the category object for every category that belongs to the set category, e.g.

{% for category in your_category.categories %}
         {{ category.title }}
{% endfor %}