Some shops like to show it all: every product, from every category. Here’s a quick and easy way to approach it.

How to Show All Products in Every Category

How to Show All Products in Every Category

Showing every product in every category, is not terribly challening once you have the right approach. The basic strategy involves:

  • Load all the categories
  • Loop through the categories
  • In each category, load all the products assigned to it
  • Show the products

Most of the time, this sort of layout will appear on the main store page, or in Shopp-terms, the catalog landing page. If that’s what you’re after, you’ll want to add your code to the catalog.php template file in your active WordPress theme.

<?php if ( shopp('storefront.has-categories') ): 
    while ( shopp('storefront.categories') ): ?>
    <?php shopp('storefront.category','slug='.shopp('category.get-slug') ); ?>
<?php endwhile; endif; ?>

Let’s break down how this works. shopp('storefront.has-categories') is used to load all the categories and check that the store has categories. Being sure that categories do exist, the while loop starts to loop through each of the entries of categories in the store. This is really just looping through the list of categories, but we’re not actually loading the categories until the shopp('storefront.category') tag. At that point we pass the name of the category in the loop as the slug option in shopp('storefront.category') so that it loads the category and automatically renders it using our standard category.php template file.

You could, of course, alter this and provide a custom layout instead by adding a load=true option to the shopp(‘storefront.category’)` tag:

<?php if ( shopp('storefront.has-categories') ): 
    while ( shopp('storefront.categories') ): ?>
    <li><h1><?php shopp(''); ?></h1>
    <?php shopp('storefront.category','load=true&slug='.shopp('category.get-slug') ); ?>

    <?php if(shopp('category','hasproducts','load=coverimages')): ?>
    <div class="product">
        <a href="<?php shopp('product','url'); ?>"><?php shopp('product','coverimage','setting=thumbnails'); ?></a>
        <h4 class="name"><a href="<?php shopp('product','url'); ?>"><?php shopp('product','name'); ?></a></h4>
    <?php endif; ?>
<?php endwhile; endif; ?>

This is probably not the best approach for a shop with hundreds of categories and hundreds of products per category. But for small shops with maybe 10-20 products in a handful of categories, this example provides a nice alternative way of showcasing everything quickly and easily, all on one page.


Jonathan was born at an early age and began designing and developing shortly after. He is the founder of Ingenesis Limited and Project Lead on the Shopp e-commerce plugin for WordPress. He lives and works in the heart of the midwest US with his family. He fancies himself a designer of code, and is only slightly addicted to coffee.

You must be logged in to post a comment.

© Ingenesis Limited. Shopp™ is a registered trademark of Ingenesis Limited.