Skip to content

Instantly share code, notes, and snippets.

@woogists
Last active November 26, 2021 23:25
Show Gist options
  • Select an option

  • Save woogists/f6f2ec75fce3b56cc80b446c50689c7d to your computer and use it in GitHub Desktop.

Select an option

Save woogists/f6f2ec75fce3b56cc80b446c50689c7d to your computer and use it in GitHub Desktop.
[Theming Snippets] Change number of upsells output
/**
* 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;
}
@kevinmamaqi
Copy link

The filter should be woocommerce_upsell_display_args

@rockythemes
Copy link

Kevin is right. The woocommerce_output_related_products_args will not affect the Upsells on the actual Product page.

Use the woocommerce_upsell_display_args filter instead.

@ChazzLayne
Copy link

Can we just ban Woo from the internet and save the world from this kind of incompetence? If monkeys had keyboards...

@de-b
Copy link

de-b commented Jan 2, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment