Add ‘Related Products’ to the Product Template in the Shopp WordPress Plugin

Problem: Today I needed to add some code to a Shopp (ver 1.1.9) product.php template so that related products (that have same ‘Tag’) would show up at the bottom. The ‘Related Products‘ template tag was not behaving as I expected it to.. i.e. it was stopping the product page rendering anything at all.

Fix: After chatting to some of the support Mods on IRC (thanks @TheWebBaker and @umargl0bal, it seemed I might need to reset the category query (category docs- see ‘reset’ option) after calling ‘Related Products‘, but this didn’t work. I turns out (sort of obviously in hindsight) that the product query needed to be reset instead (product docs – see ‘reset’ option). Here’s some working code inside product.php:

<?php shopp('catalog', 'related-products'); ?>
<?php shopp('catalog', 'product', 'reset=1'); ?>

That code can be placed anywhere in the product template but it makes sense to put it at the beginning or end of the product listing.


  • If you want to show random products you can use the ‘order=random’ option in the ‘related-products’ tab (see below for an example).
  • If you want to limit the number of related products shown, use the ‘show=#’ option also (see below for example).
<?php shopp('catalog', 'related-products','show=3&order=random'); ?>
  • The related items will be rendered using the category.php template. If you want to create a custom template JUST for related items (you really do) then copy category.php as category-related.php and customise that. This new template file will be called to render the related products.
Any Questions? Try me, or IRC or the Shopp Support site 🙂

One thought on “Add ‘Related Products’ to the Product Template in the Shopp WordPress Plugin”

  1. Hi,

    I was wondering if you could help me find a better way to handle adding “related products”. Currently I’m doing it via the template. But since the site will be turned over to the client who are non technical, adding related product via the template is agonizing for them.

    Is there a way that this can be done via the dashboard?


Leave a Reply

Your email address will not be published. Required fields are marked *