Forum
Shop Categories
I have my categories set up on Perch Admin. The set is named 'shop' and there are 5 categories underneath. I've applied these categories to my various products. However when I click on any of the category links on the shop listings page; all products display regardless. What am I doing wrong?
On my shop listing page I have the following; (note/question; is perch_categories still supported? when I place perch_shop_categories here, it breaks the listings page)
<?php perch_categories([
'template' => 'category.html',
'category' => 'shop/'.perch_get('category'),
]
); ?>
here is the category.html template (stored within /templates/categories)
<perch:before><ul class="catlist"></perch:before>
<li class="cat-list" style="margin-left: <perch:category id="catDepth" type="hidden" />0px;">
<a class="cat-link" href="index.php?cat=<perch:category id="categorySlug" />"><perch:shop id="categoryTitle" />
<h4><perch:category id="catTitle" type="smarttext" label="Title" required="true" /></h4>
<perch:category id="catSlug" type="slug" for="catTitle" suppress="true" />
<perch:category id="desc" type="textarea" label="Description" editor="markitup" markdown="true" size="s" />
</a></li>
<perch:after></ul></perch:after>
and here is where my categories are identified on the product.html template
<perch:categories id="shop" set="shop" label="Category">
<perch:category id="categorySlug" />
</perch:categories>
When you call
perch_products()
are you passing in the selected category from the URL?This what I currently have for perch_shop_products. If I passed the category.html template through this, nothing will get displayed.
If you want to filter by category, you'll need to set the
category
option.I'm sorry but I don't follow what you mean here... where do I set the 'category' option? can you provide an example?
Hello Cormac,
To filter by the category
tops
in the category setproducts
:To filter by the category
tops/polos
in the category setproducts
:To learn more about Category Filtering: https://docs.grabaperch.com/perch/categories/filtering/