1. Documentation /
  2. Change number of upsells output

Change number of upsells output

Note: We are unable to provide support for customizations under our Support Policy. If you need to further customize a snippet, or extend its functionality, we highly recommend Codeable, or a Certified WooExpert.

Add code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Code snippets plugin. Avoid adding custom code directly to your parent theme’s functions.php file as this will be wiped entirely when you update the theme.

/**
* Change number of upsells output
*/
add_filter( 'woocommerce_upsell_display_args', 'wc_change_number_related_products', 20 );
function wc_change_number_related_products( $args ) {
$args['posts_per_page'] = 1;
$args['columns'] = 4; //change number of upsells here
return $args;
}