Eren Labs JOURNAL TR
Product Catalog

WooCommerce Related Products: How They’re Chosen, and How to Make Them Relevant

WooCommerce's related products come from shared categories and tags, picked at random from a cached list. Exactly how they are chosen, why they look random or don't appear, how to change the count or the rules, and how better categories fix them.

In this article10 sections

WooCommerce related products are chosen automatically from products that share at least one category or tag with the product being viewed. WooCommerce collects those, keeps the list for a day, shuffles it, and shows four at random. There is no setting for it in the admin, so to make related products relevant you either tidy up your categories and tags, or change the rules with a few lines of code. This guide explains the selection exactly as WooCommerce’s code does it (version 11.3.1), why related products look random or don’t appear, and how to fix both.

Illustration: related products drawn at random from all products sharing a category or tag, from a list kept for a day
WooCommerce collects products sharing any category or tag, keeps the list for a day, and shows four of them at random.

According to WooCommerce’s related products function and the query behind it:

  1. It takes the product’s categories and tags.
  2. It finds published products that share any one of them. One shared tag is enough.
  3. It leaves out the product itself, its upsells, products hidden from the catalogue, and out-of-stock products if you hide those from the catalogue.
  4. It stores a list of candidates (a few more than it needs) for one day.
  5. On each page load it shuffles that list and shows four, in four columns, in random order.

Nothing about sales, price, colour or what customers actually buy together goes into it. Two products are “related” if they share any category or any tag, however broad.

Because of rule 2, the broadest term a product belongs to decides the pool. Typical culprits:

  • Collection categories like Sale, New arrivals or Gifts. A linen shirt in “Sale” is related to every other sale item, mugs included.
  • Broad tags like “summer”, “bestseller” or “free shipping”. Each one links everything that carries it.
  • Parent categories assigned together with their children. A product in both “Clothing” and “Shirts” draws from all of Clothing.
  • Uncategorized. Products left there are related to each other, whatever they are.

The shuffle makes it look worse: a shopper who reloads sees a different set each time, drawn from the same mixed pool. And because the list is cached for a day, a fix you make to categories may not show for up to 24 hours. Updating a product clears its own cached list straight away; WooCommerce’s “Clear transients” tool under Status → Tools does not clear these lists, so for other products, wait out the day.

CauseFix
The product has no category and no tag (so no related products at all)Give it a real category
It is the only product in its categories and tagsAdd a broader but sensible category, or a shared tag
Every match is out of stock and you hide out-of-stock itemsRestock, or accept fewer
Every match is set to Hidden or Search results onlyCheck Catalog visibility on those products
The candidates are all upsells of this productUpsells are shown in their own section instead
The theme or a page builder removed the sectionCheck the single product template or builder layout
A recent change hasn’t appeared yetUpdate the product, or wait for the day-long cache

In a block theme, related products come from the Related Products block in the Single Product template (Appearance → Editor → Templates), so check it is still there if the section vanished after a theme change.

WooCommerce has two hand-picked alternatives under Product data → Linked Products. Upsells appear on the product page as “You may also like”, typically a better or bigger version. Cross-sells appear in the cart, typically accessories. Both are exactly what you pick, in every case. Related products are the automatic fallback for everything you haven’t hand-picked. For a small range of key products, hand-picked upsells beat any rule; for hundreds of products, you need the automatic version to be good.

WooCommerce has no settings screen for related products, but it has filters. Add these with a code snippets plugin or a child theme.

Show more or fewer:

add_filter( 'woocommerce_output_related_products_args', function ( $args ) {
    $args['posts_per_page'] = 8;
    $args['columns']        = 4;
    return $args;
} );

Relate by category only, ignoring tags:

add_filter( 'woocommerce_product_related_posts_relate_by_tag', '__return_false' );

Ignore collection categories such as Sale or New, so they don’t widen the pool (replace the IDs with yours):

add_filter( 'woocommerce_get_related_product_cat_terms', function ( $term_ids ) {
    return array_values( array_diff( $term_ids, array( 31, 32 ) ) );
} );

That last one is the most useful for most shops: it keeps collection categories working for browsing while related products stick to the product-type categories. After adding any of them, expect the change to reach every product within a day, as the cached lists expire; update a product to see its result at once.

The real fix: categories that say what a product is#

Since related products follow categories and tags, better related products start with a better structure:

  1. Put each product in its most specific category, such as “Linen shirts” rather than only “Clothing”. WooCommerce category pages already include products from subcategories in classic shop pages, so you rarely need to tick the parent too.
  2. Keep tags few and meaningful, or stop relating by tag with the snippet above.
  3. Exclude collection categories from relating, as shown above, so Sale and New stay useful for browsing without polluting related products.
  4. Empty Uncategorized.

When a product type is better described by an attribute, such as material or colour, a category for it can work for both browsing and related products; our guide to attributes vs categories helps decide. For how categories show on the shop page, see our guide to showing categories on the WooCommerce shop page.

Before changing anything, look at what shoppers actually see on your top products:

  1. Take your ten best-selling products from Analytics → Products.
  2. Open each in a private window and reload it three times. Note any related product that a customer of this product would never buy.
  3. For each odd one, open both products and compare their categories and tags. The shared term is your culprit.
  4. Make a short list of the culprit terms. Usually it is two or three: a collection category, a seasonal tag, a parent category ticked by habit.
  5. Fix those terms once (remove the tag, exclude the category from relating, untick the parent), update the ten products so their lists refresh, and repeat the check.

Because the same few terms cause most of the mess, fixing them improves related products across the whole catalogue, not just the ten you checked.

Related products are the last thing on a product page, and most shoppers never scroll that far. Their real value is for the shopper who has decided this product isn’t quite right: the related row is what stops them going back to search. That shopper needs alternatives, the same kind of product in another colour, cut or price, not accessories. Accessories belong in cross-sells in the cart, where the decision to buy has been made.

So judge related products by one question: if this product is wrong for me, does the row show me what to look at instead? If it does, the section earns its place; if it shows random items, it is better removed than left as noise. Our guide to default variations covers another way to show alternatives right at the top of the page.

Narrow categories without the upkeep: Smart Categories#

The catch with specific categories is keeping them filled. Smart Categories is our plugin for that: the free version on WordPress.org fills an ordinary WooCommerce category from rules, such as “name contains linen AND product type is shirt”, combining AND, OR and NOT across 35+ fields, with a live preview of which products match. Membership refreshes when products, prices or stock change and in a daily sweep, and products you assigned by hand stay put.

Smart Categories: creating a rule-based category from templates or conditions such as product name contains
Smart Categories: build a narrow category from rules, such as name contains linen AND colour is white, and keep it current automatically.

An honest warning that follows from how related products work: the same plugin also makes broad collections easy, such as On Sale or New Arrivals. Those are great for browsing, but every product in them becomes “related” to every other. Use the category exclusion snippet above for those collections, and let the narrow, product-type categories drive related products. Smart Categories Pro adds subcategories generated per attribute value, such as one per colour, if you want “white linen shirts” as its own category. Our overview of WooCommerce product category plugins and our guides to an automatic sale category and a new arrivals category cover those collections.

WooCommerce related products: frequently asked questions#


How does WooCommerce choose related products?

It finds published products that share at least one category or tag with the current product, leaves out the product itself, its upsells, hidden products and, if you hide them, out-of-stock products. It caches the list for a day, shuffles it on each page load and shows four.


Why are my WooCommerce related products not relevant?

Any shared category or tag is enough, so broad terms like Sale, New arrivals, a parent category or a tag like summer link unrelated products. Put products in specific categories, keep tags few, and exclude collection categories from relating with the woocommerce_get_related_product_cat_terms filter.


Why are related products not showing in WooCommerce?

Usually the product has no category or tag, is alone in them, or every match is hidden, out of stock with hiding on, or an upsell. A theme or block template can also remove the section. Changes can take up to a day because the list is cached; updating the product refreshes its own list.


How do I change the number of related products?

Use the woocommerce_output_related_products_args filter to set posts_per_page and columns, for example 8 products in 4 columns. In block themes, the Related Products block in the Single Product template has its own settings in the Site Editor.


What is the difference between related products and upsells?

Upsells are products you pick by hand under Linked Products and show on the product page; cross-sells are hand-picked for the cart. Related products are chosen automatically from shared categories and tags, and exclude the product’s upsells so they aren’t shown twice.


More in Product Catalog

Keep exploring

All articles
Before you go Let Smart Categories do this in WooCommerce

Define the rules for a WooCommerce category once. Matching products enter automatically and leave when they no longer qualify.

Explore Smart Categories Get the free version

Free version on WordPress.org · Pro from $59/year