WooCommerce: How to Change the Number of Related Products or UpSells on Product Posts

How To  Last Updated: Time to Read: Less than a minute

WooCommerce has a default number of 2 and 1 for related products and upsells. In some themes, we have added a custom function that increases this number, but you may want to customize this anyway.

Difficulty: Moderate

Requires a Child Theme or Extension

  1. Open the functions.php file for your child theme and add the following code to the bottom
  2. If your file has a
    ?>
    at the end, remove it
  3. Alternatively, create a new file such as
    woocommerce-config.php
    and add it to your child-theme’s includes folder.
    • Do not add these functions to your parent theme in a new file or it may cause a function conflict!

In each function, the number of images and columns is defined inside the display brackets (3,1)

3 products in 1 row is ideal to the theme’s design.

Make sure there is not a blank line at the bottom of the file, then save and upload your changes.

For updated code or further support for WooCommerce customization, visit the WooCommerce website.

To learn how best to setup WooCommerce you can view this tutorial on Treehouse.